From ebf053ab30ea3e23c8035ba0c541e87502f94920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Sun, 8 Sep 2024 16:34:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(app):=20=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E7=BC=96=E8=BE=91SQL=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/AppTabbarController.java | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) 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)); + } }