From 0a9983ffa30f282d3ba3a895fd8f345537beb6be Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Tue, 28 Sep 2021 17:22:12 +0800 Subject: [PATCH] role --- .../service/impl/AccessUserServiceImpl.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java index 33523b33..96619603 100755 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java @@ -179,19 +179,22 @@ public class AccessUserServiceImpl implements AccessUserService { accessUserWrapper.eq(AccessUserRole::getLoginName, loginName); List accessUserRoles = accessUserRoleMapper.selectList(accessUserWrapper); Set roleCodeSet = accessUserRoles.stream().map(AccessUserRole::getRoleCode).collect(Collectors.toSet()); - - LambdaQueryWrapper accessRoleAuthorityWrapper = Wrappers.lambdaQuery(); - accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction); - accessRoleAuthorityWrapper.in(AccessRoleAuthority::getRoleCode, roleCodeSet); - List accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper); - List authorities = accessRoleAuthorities.stream() - .map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat(":").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList()); - + if (roleCodeSet.size() < 1) { + gaeaUser.setAuthorities(new ArrayList<>()); + }else { + LambdaQueryWrapper accessRoleAuthorityWrapper = Wrappers.lambdaQuery(); + accessRoleAuthorityWrapper.select(AccessRoleAuthority::getTarget, AccessRoleAuthority::getAction); + accessRoleAuthorityWrapper.in(AccessRoleAuthority::getRoleCode, roleCodeSet); + List accessRoleAuthorities = accessRoleAuthorityMapper.selectList(accessRoleAuthorityWrapper); + List authorities = accessRoleAuthorities.stream() + .map(accessRoleAuthority -> accessRoleAuthority.getTarget().concat(":").concat(accessRoleAuthority.getAction())).distinct().collect(Collectors.toList()); + gaeaUser.setAuthorities(authorities); + } gaeaUser.setLoginName(loginName); gaeaUser.setRealName(accessUser.getRealName()); gaeaUser.setToken(token); - gaeaUser.setAuthorities(authorities); + String gaeaUserStr = JSONObject.toJSONString(gaeaUser); cacheHelper.stringSetExpire(userKey, gaeaUserStr, 3600);