|
@@ -1,6 +1,7 @@
|
|
|
package com.lantone.security.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -145,6 +146,7 @@ public class RoleManagementFacade {
|
|
|
}
|
|
|
Role role = new Role();
|
|
|
BeanUtils.copyProperties(addRoleVO, role);
|
|
|
+ role.setCreator(SysUserUtils.getCurrentPrincipleId()+"");
|
|
|
role.setGmtCreate(DateUtil.now());
|
|
|
if (roleFacade.save(role)) {
|
|
|
//2.插入角色与系统菜单的对应关系以及角色与功能权限的对应关系sys_role_software_menu,sys_role_software_resource
|
|
@@ -171,15 +173,18 @@ public class RoleManagementFacade {
|
|
|
if(ListUtil.isNotEmpty(softwares)){
|
|
|
softwares.stream().forEach(addRoleSoftwareVO -> {
|
|
|
//获取菜单比对插入的功能菜单都能正常使用
|
|
|
+ List<SoftwareMenu> softwareMenus = softwareMenuFacade.list(new QueryWrapper<SoftwareMenu>()
|
|
|
+ .select("menu_id")
|
|
|
+ .eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
+ .in("id",addRoleSoftwareVO.getSoftwareMenuIds()));
|
|
|
+ if(ListUtil.isEmpty(softwareMenus)){
|
|
|
+ Asserts.fail("该功能菜单不存在,刷新后重新添加~");
|
|
|
+ }
|
|
|
if(ListUtil.isNotEmpty(addRoleSoftwareVO.getSoftwareMenuIds())){
|
|
|
if(addRoleSoftwareVO.getSoftwareMenuIds().size()!= menuFacade.count(new QueryWrapper<Menu>()
|
|
|
.eq("status", StatusEnum.Enable.getKey())
|
|
|
.eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
- .in("id",softwareMenuFacade.list(new QueryWrapper<SoftwareMenu>()
|
|
|
- .select("menu_id")
|
|
|
- .eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
- .in("id",addRoleSoftwareVO.getSoftwareMenuIds()))
|
|
|
- .stream().map(SoftwareMenu::getMenuId).collect(Collectors.toList())))){
|
|
|
+ .in("id",softwareMenus.stream().map(SoftwareMenu::getMenuId).collect(Collectors.toList())))){
|
|
|
Asserts.fail("该角色要绑定的功能菜单已更新请刷新重试~");
|
|
|
}
|
|
|
}
|
|
@@ -187,15 +192,18 @@ public class RoleManagementFacade {
|
|
|
//获取菜单比对插入的功能菜单都能正常使用
|
|
|
if(ListUtil.isNotEmpty(addRoleSoftwareVO.getSoftwareResourceIds())){
|
|
|
//去重 菜单对应的功能权限可能是一个
|
|
|
+ List<SoftwareResource> softwareResources = softwareResourceFacade.list(new QueryWrapper<SoftwareResource>()
|
|
|
+ .select("resource_id")
|
|
|
+ .eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
+ .in("id",addRoleSoftwareVO.getSoftwareResourceIds()));
|
|
|
+ if(ListUtil.isEmpty(softwareResources)){
|
|
|
+ Asserts.fail("该功能菜单不存在,刷新后重新添加~");
|
|
|
+ }
|
|
|
Set resourceSet = new HashSet(addRoleSoftwareVO.getSoftwareResourceIds());
|
|
|
if(resourceSet.size()!= resourceFacade.count(new QueryWrapper<Resource>()
|
|
|
.eq("status", StatusEnum.Enable.getKey())
|
|
|
.eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
- .in("id",softwareResourceFacade.list(new QueryWrapper<SoftwareResource>()
|
|
|
- .select("resource_id")
|
|
|
- .eq("is_deleted",IsDeleteEnum.N.getKey())
|
|
|
- .in("id",addRoleSoftwareVO.getSoftwareResourceIds()))
|
|
|
- .stream().map(SoftwareResource::getResourceId).collect(Collectors.toList())))){
|
|
|
+ .in("id",softwareResources.stream().map(SoftwareResource::getResourceId).collect(Collectors.toList())))){
|
|
|
Asserts.fail("该角色要绑定的功能菜单已更新请刷新重试~");
|
|
|
}
|
|
|
}
|
|
@@ -305,7 +313,7 @@ public class RoleManagementFacade {
|
|
|
* @Description通过角色id获取角色详情
|
|
|
* @Return com.lantone.common.dto.GetRoleDTO
|
|
|
*/
|
|
|
- public GetRoleDTO getRoleById(Long roleId) {
|
|
|
+ public GetRoleDTO getRoleById(Long roleId,String type) {
|
|
|
GetRoleDTO getRoleDTO = new GetRoleDTO();
|
|
|
//1.获取角色基本信息
|
|
|
List<Role> roles = roleFacade.list(new QueryWrapper<Role>()
|
|
@@ -318,7 +326,7 @@ public class RoleManagementFacade {
|
|
|
List<Long> loginRoles = userRoleFacade.getBaseMapper().getUserRoles(SysUserUtils.getCurrentPrincipleId())
|
|
|
.stream().map(UserRoleDTO::getRoleId).collect(Collectors.toList());
|
|
|
if(ListUtil.isNotEmpty(loginRoles)){
|
|
|
- List<UserMenuResourceTreeDTO> userMenuResourceTreeDTOS = getUserMenuResourceTreeByRoles(loginRoles, roles.stream().map(Role::getId).collect(Collectors.toList()));
|
|
|
+ List<UserMenuResourceTreeDTO> userMenuResourceTreeDTOS = getUserMenuResourceTreeByRoles(loginRoles, roles.stream().map(Role::getId).collect(Collectors.toList()),type);
|
|
|
//获取用户服务
|
|
|
List<SoftwareDTO> loginSoftwares = softwareFacade.getBaseMapper().getUserSoftware(loginRoles);
|
|
|
List<Long> hasSoftwareIds = softwareFacade.getBaseMapper().getUserSoftware(roles.stream().map(Role::getId).collect(Collectors.toList()))
|
|
@@ -394,12 +402,12 @@ public class RoleManagementFacade {
|
|
|
* @param获取用户功能菜单树
|
|
|
* @Return java.util.Map<java.lang.Long, java.util.List < com.lantone.common.dto.UserMenuResourceTreeDTO>>
|
|
|
*/
|
|
|
- public List<UserMenuResourceTreeDTO> getUserMenuResourceTree() {
|
|
|
+ public List<UserMenuResourceTreeDTO> getUserMenuResourceTree(String type) {
|
|
|
//1.获取当前用户的角色列表
|
|
|
List<Long> roles = userRoleFacade.getBaseMapper().getUserRoles(SysUserUtils.getCurrentPrincipleId())
|
|
|
.stream().map(UserRoleDTO::getRoleId).collect(Collectors.toList());
|
|
|
if(ListUtil.isNotEmpty(roles)){
|
|
|
- return getUserMenuResourceTreeByRoles(roles);
|
|
|
+ return getUserMenuResourceTreeByRoles(roles,type);
|
|
|
}else {
|
|
|
Asserts.fail("当前登录用户无角色信息");
|
|
|
}
|
|
@@ -411,8 +419,15 @@ public class RoleManagementFacade {
|
|
|
* @Description通过角色列表获取用户功能菜单树
|
|
|
* @Return java.util.Map<java.lang.Long, java.util.List < com.lantone.common.dto.UserMenuResourceTreeDTO>>
|
|
|
*/
|
|
|
- private List<UserMenuResourceTreeDTO> getUserMenuResourceTreeByRoles(List<Long> roles) {
|
|
|
- List<UserMenuResourceTreeDTO> userMenuResourceTree = roleSoftwareMenuFacade.getBaseMapper().getUserMenuResourceTree(roles);
|
|
|
+ private List<UserMenuResourceTreeDTO> getUserMenuResourceTreeByRoles(List<Long> roles,String type) {
|
|
|
+ List hideMenus = null;
|
|
|
+ //获取type下要隐藏的菜单
|
|
|
+ List<GetDictionaryInfoByTypeDTO> configHideMenus = dictionaryInfoFacade.getBaseMapper()
|
|
|
+ .getDictionaryInfoByType(DictionaryEnum.MANAGE_HIDE_MENU.getKey());
|
|
|
+ if(ListUtil.isNotEmpty(configHideMenus)){
|
|
|
+ hideMenus = JSONArray.parseArray(JSONObject.parseObject(configHideMenus.get(0).getVal()).getString(type));
|
|
|
+ }
|
|
|
+ List<UserMenuResourceTreeDTO> userMenuResourceTree = roleSoftwareMenuFacade.getBaseMapper().getUserMenuResourceTree(roles,hideMenus);
|
|
|
return getTree(userMenuResourceTree);
|
|
|
}
|
|
|
|
|
@@ -422,8 +437,15 @@ public class RoleManagementFacade {
|
|
|
* @Description通过角色列表获取用户功能菜单树
|
|
|
* @Return java.util.Map<java.lang.Long, java.util.List < com.lantone.common.dto.UserMenuResourceTreeDTO>>
|
|
|
*/
|
|
|
- private List<UserMenuResourceTreeDTO> getUserMenuResourceTreeByRoles(List<Long> loginRoles, List<Long> selectRoles) {
|
|
|
- List<UserMenuResourceTreeDTO> userMenuResourceTree = roleSoftwareMenuFacade.getBaseMapper().getMenuResourceRelation(loginRoles, selectRoles);
|
|
|
+ private List<UserMenuResourceTreeDTO> getUserMenuResourceTreeByRoles(List<Long> loginRoles, List<Long> selectRoles,String type) {
|
|
|
+ List hideMenus = null;
|
|
|
+ //获取type下要隐藏的菜单
|
|
|
+ List<GetDictionaryInfoByTypeDTO> configHideMenus = dictionaryInfoFacade.getBaseMapper()
|
|
|
+ .getDictionaryInfoByType(DictionaryEnum.MANAGE_HIDE_MENU.getKey());
|
|
|
+ if(ListUtil.isNotEmpty(configHideMenus)){
|
|
|
+ hideMenus = JSONArray.parseArray(JSONObject.parseObject(configHideMenus.get(0).getVal()).getString(type));
|
|
|
+ }
|
|
|
+ List<UserMenuResourceTreeDTO> userMenuResourceTree = roleSoftwareMenuFacade.getBaseMapper().getMenuResourceRelation(loginRoles, selectRoles,hideMenus);
|
|
|
return getTree(userMenuResourceTree);
|
|
|
}
|
|
|
|