菜单新增是否显示字段
This commit is contained in:
@@ -127,6 +127,12 @@ public class Menu implements Serializable {
|
|||||||
@Schema(description = "是否打开新页面")
|
@Schema(description = "是否打开新页面")
|
||||||
private Integer isOpen;
|
private Integer isOpen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否显示
|
||||||
|
*/
|
||||||
|
@Schema(description = "是否显示")
|
||||||
|
private Integer isDisplay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -101,4 +101,9 @@ public class MenuVO extends Menu implements INode<MenuVO> {
|
|||||||
* 是否新窗口打开
|
* 是否新窗口打开
|
||||||
*/
|
*/
|
||||||
private String isOpenName;
|
private String isOpenName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否显示
|
||||||
|
*/
|
||||||
|
private String isDisplayName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<result column="category" property="category"/>
|
<result column="category" property="category"/>
|
||||||
<result column="action" property="action"/>
|
<result column="action" property="action"/>
|
||||||
<result column="is_open" property="isOpen"/>
|
<result column="is_open" property="isOpen"/>
|
||||||
|
<result column="is_display" property="isDisplay"/>
|
||||||
<result column="remark" property="remark"/>
|
<result column="remark" property="remark"/>
|
||||||
<result column="is_deleted" property="isDeleted"/>
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
<result column="category" property="category"/>
|
<result column="category" property="category"/>
|
||||||
<result column="action" property="action"/>
|
<result column="action" property="action"/>
|
||||||
<result column="is_open" property="isOpen"/>
|
<result column="is_open" property="isOpen"/>
|
||||||
|
<result column="is_display" property="isDisplay"/>
|
||||||
<result column="remark" property="remark"/>
|
<result column="remark" property="remark"/>
|
||||||
<result column="is_deleted" property="isDeleted"/>
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
<result column="has_children" property="hasChildren"/>
|
<result column="has_children" property="hasChildren"/>
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
|||||||
private final ITopMenuSettingService topMenuSettingService;
|
private final ITopMenuSettingService topMenuSettingService;
|
||||||
private final static String PARENT_ID = "parentId";
|
private final static String PARENT_ID = "parentId";
|
||||||
private final static Integer MENU_CATEGORY = 1;
|
private final static Integer MENU_CATEGORY = 1;
|
||||||
|
private final static Integer MENU_DISPLAY = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MenuVO> lazyList(Long parentId, Map<String, Object> param) {
|
public List<MenuVO> lazyList(Long parentId, Map<String, Object> param) {
|
||||||
@@ -132,10 +133,22 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
|||||||
roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu));
|
roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu));
|
||||||
routes.sort(Comparator.comparing(Menu::getSort));
|
routes.sort(Comparator.comparing(Menu::getSort));
|
||||||
MenuWrapper menuWrapper = new MenuWrapper();
|
MenuWrapper menuWrapper = new MenuWrapper();
|
||||||
List<Menu> collect = routes.stream().filter(x -> Func.equals(x.getCategory(), 1)).collect(Collectors.toList());
|
Map<Long, Menu> routeMap = routes.stream().collect(Collectors.toMap(Menu::getId, x -> x, (left, right) -> left));
|
||||||
|
List<Menu> collect = routes.stream()
|
||||||
|
.filter(x -> Func.equals(x.getCategory(), 1))
|
||||||
|
.filter(x -> isDisplayMenu(x, routeMap))
|
||||||
|
.collect(Collectors.toList());
|
||||||
return menuWrapper.listNodeVO(collect);
|
return menuWrapper.listNodeVO(collect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isDisplayMenu(Menu menu, Map<Long, Menu> routeMap) {
|
||||||
|
if (!Func.equals(Func.toInt(menu.getIsDisplay(), MENU_DISPLAY), MENU_DISPLAY)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Menu parentMenu = routeMap.get(menu.getParentId());
|
||||||
|
return parentMenu == null || isDisplayMenu(parentMenu, routeMap);
|
||||||
|
}
|
||||||
|
|
||||||
private void recursion(List<Menu> allMenus, List<Menu> routes, Menu roleMenu) {
|
private void recursion(List<Menu> allMenus, List<Menu> routes, Menu roleMenu) {
|
||||||
Optional<Menu> menu = allMenus.stream().filter(x -> Func.equals(x.getId(), roleMenu.getParentId())).findFirst();
|
Optional<Menu> menu = allMenus.stream().filter(x -> Func.equals(x.getId(), roleMenu.getParentId())).findFirst();
|
||||||
if (menu.isPresent() && !routes.contains(menu.get())) {
|
if (menu.isPresent() && !routes.contains(menu.get())) {
|
||||||
@@ -306,6 +319,9 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
|
|||||||
if (menu.getParentId() == null) {
|
if (menu.getParentId() == null) {
|
||||||
menu.setParentId(BladeConstant.TOP_PARENT_ID);
|
menu.setParentId(BladeConstant.TOP_PARENT_ID);
|
||||||
}
|
}
|
||||||
|
if (menu.getIsDisplay() == null) {
|
||||||
|
menu.setIsDisplay(MENU_DISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
// 验证父节点类型(新增或父节点变更时)
|
// 验证父节点类型(新增或父节点变更时)
|
||||||
if (isNewMenu || menu.getParentId() != null) {
|
if (isNewMenu || menu.getParentId() != null) {
|
||||||
|
|||||||
@@ -63,9 +63,11 @@ public class MenuWrapper extends BaseEntityWrapper<Menu, MenuVO> {
|
|||||||
String category = DictCache.getValue(DictEnum.MENU_CATEGORY, Func.toInt(menuVO.getCategory()));
|
String category = DictCache.getValue(DictEnum.MENU_CATEGORY, Func.toInt(menuVO.getCategory()));
|
||||||
String action = DictCache.getValue(DictEnum.BUTTON_FUNC, Func.toInt(menuVO.getAction()));
|
String action = DictCache.getValue(DictEnum.BUTTON_FUNC, Func.toInt(menuVO.getAction()));
|
||||||
String open = DictCache.getValue(DictEnum.YES_NO, Func.toInt(menuVO.getIsOpen()));
|
String open = DictCache.getValue(DictEnum.YES_NO, Func.toInt(menuVO.getIsOpen()));
|
||||||
|
String display = Func.equals(Func.toInt(menuVO.getIsDisplay(), 1), 1) ? "显示" : "不显示";
|
||||||
menuVO.setCategoryName(category);
|
menuVO.setCategoryName(category);
|
||||||
menuVO.setActionName(action);
|
menuVO.setActionName(action);
|
||||||
menuVO.setIsOpenName(open);
|
menuVO.setIsOpenName(open);
|
||||||
|
menuVO.setIsDisplayName(display);
|
||||||
return menuVO;
|
return menuVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -556,6 +556,7 @@ CREATE TABLE `blade_menu` (
|
|||||||
`category` int NULL DEFAULT NULL COMMENT '菜单类型',
|
`category` int NULL DEFAULT NULL COMMENT '菜单类型',
|
||||||
`action` int NULL DEFAULT 0 COMMENT '操作按钮类型',
|
`action` int NULL DEFAULT 0 COMMENT '操作按钮类型',
|
||||||
`is_open` int NULL DEFAULT 1 COMMENT '是否打开新页面',
|
`is_open` int NULL DEFAULT 1 COMMENT '是否打开新页面',
|
||||||
|
`is_display` int NULL DEFAULT 1 COMMENT '是否显示',
|
||||||
`component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件地址',
|
`component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件地址',
|
||||||
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
|
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
|
||||||
|
|||||||
@@ -785,6 +785,7 @@ CREATE TABLE `blade_menu` (
|
|||||||
`category` int(11) DEFAULT NULL COMMENT '菜单类型',
|
`category` int(11) DEFAULT NULL COMMENT '菜单类型',
|
||||||
`action` int(11) DEFAULT '0' COMMENT '操作按钮类型',
|
`action` int(11) DEFAULT '0' COMMENT '操作按钮类型',
|
||||||
`is_open` int(11) DEFAULT '1' COMMENT '是否打开新页面',
|
`is_open` int(11) DEFAULT '1' COMMENT '是否打开新页面',
|
||||||
|
`is_display` int(11) DEFAULT '1' COMMENT '是否显示',
|
||||||
`component` varchar(255) DEFAULT NULL COMMENT '组件地址',
|
`component` varchar(255) DEFAULT NULL COMMENT '组件地址',
|
||||||
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
||||||
`is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除',
|
`is_deleted` int(11) DEFAULT '0' COMMENT '是否已删除',
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
INSERT INTO `blade_param` (`id`, `param_name`, `param_key`, `param_value`, `remark`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`)
|
INSERT INTO `blade_param` (`id`, `param_name`, `param_key`, `param_value`, `remark`, `create_user`, `create_dept`, `create_time`, `update_user`, `update_time`, `status`, `is_deleted`)
|
||||||
VALUES (1123598819738675204, '账号锁定时长(分钟)', 'account.lockDuration', '30', '锁定时长', 1123598821738675201, 1123598813738675201, '2025-12-01 12:00:00', 1123598821738675201, '2025-12-01 12:00:00', 1, 0);
|
VALUES (1123598819738675204, '账号锁定时长(分钟)', 'account.lockDuration', '30', '锁定时长', 1123598821738675201, 1123598813738675201, '2025-12-01 12:00:00', 1123598821738675201, '2025-12-01 12:00:00', 1, 0);
|
||||||
|
|
||||||
|
-- -----------------------------------
|
||||||
|
-- 菜单新增是否显示字段
|
||||||
|
-- -----------------------------------
|
||||||
|
ALTER TABLE `blade_menu` ADD COLUMN `is_display` int NULL DEFAULT 1 COMMENT '是否显示' AFTER `is_open`;
|
||||||
|
UPDATE `blade_menu` SET `is_display` = 1 WHERE `is_display` IS NULL;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 限流规则表
|
-- 限流规则表
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user