diff --git a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java index a7ceee904..7a596c8bc 100644 --- a/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java +++ b/pigx-app-server/pigx-app-server-biz/src/main/java/com/pig4cloud/pigx/app/controller/AppTabbarController.java @@ -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 tabbarEntityList) { - // 删除不在新增范围的导航菜单 - List idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); - List 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 tabbarEntityList) { + // 删除不在新增范围的导航菜单 + List idList = tabbarService.list().stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); + List newIdList = tabbarEntityList.stream().map(AppTabbarEntity::getId).collect(Collectors.toList()); + + // 计算需要删除的 ID 列表 + List idsToRemove = CollUtil.subtractToList(idList, newIdList); + + // 如果有需要删除的菜单,则批量删除 + if (CollUtil.isNotEmpty(idsToRemove)) { + tabbarService.removeBatchByIds(idsToRemove); + } + + return R.ok(tabbarService.saveOrUpdateBatch(tabbarEntityList)); + } }