mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
fix(app): 导航栏编辑SQL报错
This commit is contained in:
1 parent
cbb945dc7c
commit
b74424463a
1 file changed
+28
-19
+28
-19
@@ -27,26 +27,35 @@ import java.util.stream.Collectors;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class AppTabbarController {
|
||||
|
||||
private final AppTabbarService tabbarService;
|
||||
private final AppTabbarService tabbarService;
|
||||
|
||||
/**
|
||||
* 查询导航列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "查询导航列表", description = "查询导航列表")
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
return R.ok(tabbarService.list());
|
||||
}
|
||||
/**
|
||||
* 查询导航列表
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "查询导航列表", description = "查询导航列表")
|
||||
@GetMapping("/list")
|
||||
public R list() {
|
||||
return R.ok(tabbarService.list());
|
||||
}
|
||||
|
||||
@Operation(summary = "更新导航", description = "更新导航")
|
||||
@PutMapping
|
||||
public R update(@RequestBody List<AppTabbarEntity> tabbarEntityList) {
|
||||
// 删除不在新增范围的导航菜单
|
||||
List<Long> idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
List<Long> newIdList = tabbarEntityList.stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
tabbarService.removeBatchByIds(CollUtil.subtractToList(idList, newIdList));
|
||||
return R.ok(tabbarService.saveOrUpdateBatch(tabbarEntityList));
|
||||
}
|
||||
@Operation(summary = "更新导航", description = "更新导航")
|
||||
@PutMapping
|
||||
public R update(@RequestBody List<AppTabbarEntity> tabbarEntityList) {
|
||||
// 删除不在新增范围的导航菜单
|
||||
List<Long> idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
List<Long> newIdList = tabbarEntityList.stream().map(AppTabbarEntity::getId).collect(Collectors.toList());
|
||||
|
||||
// 计算需要删除的 ID 列表
|
||||
List<Long> idsToRemove = CollUtil.subtractToList(idList, newIdList);
|
||||
|
||||
// 如果有需要删除的菜单,则批量删除
|
||||
if (CollUtil.isNotEmpty(idsToRemove)) {
|
||||
tabbarService.removeBatchByIds(idsToRemove);
|
||||
}
|
||||
|
||||
return R.ok(tabbarService.saveOrUpdateBatch(tabbarEntityList));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user