【7.1.1】查询资源用set不用list

pull/22/head
fengshuonan 2021-08-11 15:05:33 +08:00
parent 41e5bc3cfb
commit bf60703048
5 changed files with 7 additions and 8 deletions

View File

@ -27,7 +27,6 @@ package cn.stylefeng.roses.kernel.system.api;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition; import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceUrlParam; import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceUrlParam;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -56,6 +55,6 @@ public interface ResourceServiceApi {
* @author fengshuonan * @author fengshuonan
* @date 2020/11/29 19:49 * @date 2020/11/29 19:49
*/ */
Set<String> getResourceUrlsListByCodes(List<String> resourceCodes); Set<String> getResourceUrlsListByCodes(Set<String> resourceCodes);
} }

View File

@ -78,7 +78,7 @@ public interface RoleServiceApi {
* @author majianguo * @author majianguo
* @date 2020/11/5 11:17 * @date 2020/11/5 11:17
*/ */
List<String> getRoleResourceCodeList(List<Long> roleIdList); Set<String> getRoleResourceCodeList(List<Long> roleIdList);
/** /**
* code * code

View File

@ -140,7 +140,7 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
if (!loginUserApi.getSuperAdminFlag()) { if (!loginUserApi.getSuperAdminFlag()) {
// 获取权限列表 // 获取权限列表
List<Long> roleIds = loginUserApi.getLoginUser().getSimpleRoleInfoList().parallelStream().map(SimpleRoleInfo::getRoleId).collect(Collectors.toList()); List<Long> roleIds = loginUserApi.getLoginUser().getSimpleRoleInfoList().parallelStream().map(SimpleRoleInfo::getRoleId).collect(Collectors.toList());
List<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds); Set<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds);
if (!resourceCodeList.isEmpty()) { if (!resourceCodeList.isEmpty()) {
sysResourceLambdaQueryWrapper.in(SysResource::getResourceCode, resourceCodeList); sysResourceLambdaQueryWrapper.in(SysResource::getResourceCode, resourceCodeList);
} }
@ -366,7 +366,7 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
} }
@Override @Override
public Set<String> getResourceUrlsListByCodes(List<String> resourceCodes) { public Set<String> getResourceUrlsListByCodes(Set<String> resourceCodes) {
if (resourceCodes == null || resourceCodes.isEmpty()) { if (resourceCodes == null || resourceCodes.isEmpty()) {
return new HashSet<>(); return new HashSet<>();

View File

@ -481,9 +481,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
} }
@Override @Override
public List<String> getRoleResourceCodeList(List<Long> roleIdList) { public Set<String> getRoleResourceCodeList(List<Long> roleIdList) {
ArrayList<String> result = new ArrayList<>(); HashSet<String> result = new HashSet<>();
for (Long roleId : roleIdList) { for (Long roleId : roleIdList) {

View File

@ -561,7 +561,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(userId); SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(userId);
// 5. 获取用户的所有资源url // 5. 获取用户的所有资源url
List<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds); Set<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds);
Set<String> resourceUrlsListByCodes = resourceServiceApi.getResourceUrlsListByCodes(resourceCodeList); Set<String> resourceUrlsListByCodes = resourceServiceApi.getResourceUrlsListByCodes(resourceCodeList);
// 6. 获取用户的所有按钮code集合 // 6. 获取用户的所有按钮code集合