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)); + } + }