From a75c4c3bd503f7ecc3ed9eb34581145e43b46714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Mon, 4 Nov 2024 22:22:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8F=9C=E5=8D=95=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harmony/controller/SystemController.java | 8 ++++++++ .../com/guaiguailang/harmony/mapper/SystemMapper.java | 6 +++--- .../guaiguailang/harmony/service/SystemService.java | 4 ++++ .../harmony/service/impl/SystemServiceImpl.java | 11 +++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/guaiguailang/harmony/controller/SystemController.java b/src/main/java/com/guaiguailang/harmony/controller/SystemController.java index 8d66e94..a8567a1 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/SystemController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/SystemController.java @@ -42,5 +42,13 @@ public class SystemController { public ResponseEntity addMenu(@RequestBody MenuDataItem menuDataItem) { return ResponseEntity.ok(systemService.addMenu(menuDataItem)); } + @DeleteMapping("menu-del") + public ResponseEntity delMenu(@RequestBody MenuDataItem menuDataItem) { + return ResponseEntity.ok(systemService.delMenu(menuDataItem)); + } + @DeleteMapping("menu-del-realy") + public ResponseEntity delMenuRealy(@RequestBody MenuDataItem menuDataItem) { + return ResponseEntity.ok(systemService.delMenuRealy(menuDataItem)); + } } diff --git a/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java b/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java index 126134d..831bcad 100644 --- a/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java +++ b/src/main/java/com/guaiguailang/harmony/mapper/SystemMapper.java @@ -15,14 +15,14 @@ public interface SystemMapper extends BaseMapper { * @param roleId * @return */ - @Select(""" - SELECT * from menu_data_item where id in (select system_role_menu.menu_id from system_role_menu where role_id=#{roleId} and deleted!=1)""") + @Select("SELECT * from menu_data_item where (deleted!=1 or deleted is null) and id in (select system_role_menu.menu_id from system_role_menu where role_id=#{roleId})") List getMenus(String roleId); /** * 查询所有菜单,不区分角色 * @return */ - @Select("SELECT * from menu_data_item where deleted!=1") + @Select("SELECT * from menu_data_item") List getMenusAll(); + } diff --git a/src/main/java/com/guaiguailang/harmony/service/SystemService.java b/src/main/java/com/guaiguailang/harmony/service/SystemService.java index 87e0363..38eaa97 100644 --- a/src/main/java/com/guaiguailang/harmony/service/SystemService.java +++ b/src/main/java/com/guaiguailang/harmony/service/SystemService.java @@ -11,4 +11,8 @@ public interface SystemService { ResponseResult updateMenu(MenuDataItem menuDataItem); ResponseResult addMenu(MenuDataItem menuDataItem); + + ResponseResult delMenu(MenuDataItem menuDataItem); + + ResponseResult delMenuRealy(MenuDataItem menuDataItem); } diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java index 3ca885d..4a11187 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/SystemServiceImpl.java @@ -77,4 +77,15 @@ public class SystemServiceImpl implements SystemService { } } + @Override + public ResponseResult delMenu(MenuDataItem menuDataItem) { + menuDataItem.setDeleted(1); + return ResponseResult.success(systemMapper.updateById(menuDataItem)); + } + + @Override + public ResponseResult delMenuRealy(MenuDataItem menuDataItem) { + return ResponseResult.success(systemMapper.deleteById(menuDataItem)); + } + }