feat: 菜单删除功能完成

This commit is contained in:
萌狼蓝天 2024-11-04 22:22:26 +08:00
parent 8e63cb4ef9
commit a75c4c3bd5
4 changed files with 26 additions and 3 deletions

View File

@ -42,5 +42,13 @@ public class SystemController {
public ResponseEntity addMenu(@RequestBody MenuDataItem menuDataItem) { public ResponseEntity addMenu(@RequestBody MenuDataItem menuDataItem) {
return ResponseEntity.ok(systemService.addMenu(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));
}
} }

View File

@ -15,14 +15,14 @@ public interface SystemMapper extends BaseMapper<MenuDataItem> {
* @param roleId * @param roleId
* @return * @return
*/ */
@Select(""" @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})")
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)""")
List<MenuDataItem> getMenus(String roleId); List<MenuDataItem> getMenus(String roleId);
/** /**
* 查询所有菜单不区分角色 * 查询所有菜单不区分角色
* @return * @return
*/ */
@Select("SELECT * from menu_data_item where deleted!=1") @Select("SELECT * from menu_data_item")
List<MenuDataItem> getMenusAll(); List<MenuDataItem> getMenusAll();
} }

View File

@ -11,4 +11,8 @@ public interface SystemService {
ResponseResult updateMenu(MenuDataItem menuDataItem); ResponseResult updateMenu(MenuDataItem menuDataItem);
ResponseResult addMenu(MenuDataItem menuDataItem); ResponseResult addMenu(MenuDataItem menuDataItem);
ResponseResult delMenu(MenuDataItem menuDataItem);
ResponseResult delMenuRealy(MenuDataItem menuDataItem);
} }

View File

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