From a5fac95408a43ad43de9d88c30d06c0918c7bc8f Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Wed, 29 May 2024 11:14:44 +0800
Subject: [PATCH] 配置调整
---
src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java | 79 ++++++++++++++++++++++++++-------------
1 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java
index 3ab9b53..3e3a343 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java
@@ -1,30 +1,17 @@
-/*
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the dreamlu.net developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: Chill 庄骞 (smallchill@163.com)
- */
package org.springblade.modules.system.service.impl;
+import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
+import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.springblade.common.cache.SysCache;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.constant.BladeConstant;
+import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.node.TreeNode;
import org.springblade.core.tool.support.Kv;
@@ -42,6 +29,8 @@
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
@@ -69,7 +58,14 @@
if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) {
parentId = null;
}
- return baseMapper.lazyList(parentId, param);
+ List<MenuVO> menuVOS = baseMapper.lazyList(parentId, param);
+ for (MenuVO menuVO : menuVOS) {
+ if (StringUtils.isNotBlank(menuVO.getLabelStr())) {
+ List<List<String>> lists = (List<List<String>>) JSON.parse(menuVO.getLabelStr());
+ menuVO.setLabelList(lists);
+ }
+ }
+ return menuVOS;
}
@Override
@@ -77,15 +73,26 @@
if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) {
parentId = null;
}
- return baseMapper.lazyMenuList(parentId, param);
+ List<MenuVO> menuVOS = baseMapper.lazyList(parentId, param);
+ for (MenuVO menuVO : menuVOS) {
+ if (StringUtils.isNotBlank(menuVO.getLabelStr())) {
+ List<List<String>> lists = (List<List<String>>) JSON.parse(menuVO.getLabelStr());
+ menuVO.setLabelList(lists);
+ }
+ }
+ return menuVOS;
}
+ public static final List<Integer> list1 = Arrays.asList(1, 2, 3, 4, 5, 6, 11, null);
+ public static final List<Integer> list2 = Arrays.asList(1, 11, null);
+
+
@Override
- public List<MenuVO> routes(String roleId, Long topMenuId) {
+ public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType, Integer menuType, String roleName,String houseCode) {
if (StringUtil.isBlank(roleId)) {
return null;
}
- List<Menu> allMenus = baseMapper.allMenu();
+ List<Menu> allMenus = baseMapper.selectList(Wrappers.<Menu>lambdaQuery().eq(Menu::getCategory, 1).eq(Menu::getMenuType, menuType));
List<Menu> roleMenus;
// 超级管理员并且不是顶部菜单请求则返回全部菜单
if (AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) {
@@ -93,12 +100,12 @@
}
// 非超级管理员并且不是顶部菜单请求则返回对应角色权限菜单
else if (!AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) {
- roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId)));
+ roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId), menuType));
}
// 顶部菜单请求返回对应角色权限菜单
else {
// 角色配置对应菜单
- List<Menu> roleIdMenus = baseMapper.roleMenuByRoleId(Func.toLongList(roleId));
+ List<Menu> roleIdMenus = baseMapper.roleMenuByRoleId(Func.toLongList(roleId), menuType);
// 反向递归角色菜单所有父级
List<Menu> routes = new LinkedList<>(roleIdMenus);
roleIdMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu));
@@ -109,7 +116,21 @@
routes.stream().anyMatch(route -> route.getId().longValue() == x.getId().longValue())
).collect(Collectors.toList());
}
+
return buildRoutes(allMenus, roleMenus);
+ }
+
+ /**
+ * 房屋的时候才通过人的标签过滤
+ *
+ * @param roleMenus
+ * @param labelType
+ */
+ private void extracted(Integer labelType, List<Menu> roleMenus,String houseCode) {
+ Iterator<Menu> iterator = roleMenus.iterator();
+ while (iterator.hasNext()) {
+ Menu next = iterator.next();
+ }
}
@Override
@@ -153,8 +174,7 @@
@Override
public List<TreeNode> grantTree(BladeUser user) {
- List<TreeNode> menuTree = user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId()));
- return ForestNodeMerger.merge(tenantPackageTree(menuTree, user.getTenantId()));
+ return ForestNodeMerger.merge(AuthUtil.getUser().getRoleName().equals(RoleConstant.ADMINISTRATOR) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId())));
}
@Override
@@ -273,14 +293,14 @@
}
@Override
- public boolean submit(Menu menu) {
+ public boolean submit(MenuDTO menu) {
LambdaQueryWrapper<Menu> menuQueryWrapper = Wrappers.lambdaQuery();
if (menu.getId() == null) {
menuQueryWrapper.eq(Menu::getCode, menu.getCode()).or(
wrapper -> wrapper.eq(Menu::getName, menu.getName()).eq(Menu::getCategory, MENU_CATEGORY)
);
} else {
- menuQueryWrapper.ne(Menu::getId, menu.getId()).and(
+ menuQueryWrapper.ne(Menu::getId, menu.getId()).eq(Menu::getIsDeleted, 0).and(
wrapper -> wrapper.eq(Menu::getCode, menu.getCode()).or(
o -> o.eq(Menu::getName, menu.getName()).eq(Menu::getCategory, MENU_CATEGORY)
)
@@ -299,6 +319,13 @@
throw new ServiceException("父节点只可选择菜单类型!");
}
}
+ menu.setLabelStr(JSON.toJSONString(menu.getLabelList()));
+ List<List<String>> labelList = menu.getLabelList();
+ StringBuffer stringBuffer = new StringBuffer();
+ for (List<String> strings : labelList) {
+ stringBuffer.append(strings.get(strings.size() - 1)).append(",");
+ }
+ menu.setLabelId(stringBuffer.toString());
menu.setIsDeleted(BladeConstant.DB_NOT_DELETED);
return saveOrUpdate(menu);
}
--
Gitblit v1.9.3