|
@ -4,9 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; |
|
|
import com.epmet.bean.OpeScopeFilterResultBean; |
|
|
import com.epmet.bean.OpeScopeFilterResultBean; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.GovTokenDto; |
|
|
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|
|
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
@ -65,57 +63,11 @@ public class AccessServiceImpl implements AccessService { |
|
|
public static final String ORG_RELATION_SUP = "sup"; |
|
|
public static final String ORG_RELATION_SUP = "sup"; |
|
|
public static final String ORG_PATH_SEPARATOR = ":"; |
|
|
public static final String ORG_PATH_SEPARATOR = ":"; |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 更新权限缓存 |
|
|
|
|
|
* @param staffId |
|
|
|
|
|
* @param permissions |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void updatePermissionCache(String staffId, String app, String client, Set<String> permissions, Set<String> roleIdList, |
|
|
|
|
|
String orgIdPath, String gridId) { |
|
|
|
|
|
GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); |
|
|
|
|
|
if (govTokenDto == null) { |
|
|
|
|
|
logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId); |
|
|
|
|
|
return ; |
|
|
|
|
|
} |
|
|
|
|
|
// 将权限,角色列表,和当前组织ID存入TokenDto
|
|
|
|
|
|
govTokenDto.setPermissions(permissions); |
|
|
|
|
|
govTokenDto.setRoleIdList(roleIdList); |
|
|
|
|
|
govTokenDto.setOrgIdPath(orgIdPath); |
|
|
|
|
|
govTokenDto.setGridId(gridId); |
|
|
|
|
|
|
|
|
|
|
|
// 将新的TokenDto更新到redis中
|
|
|
|
|
|
long expire = cpUserDetailRedis.getExpire(app, client, staffId); |
|
|
|
|
|
cpUserDetailRedis.set(govTokenDto, expire); |
|
|
|
|
|
logger.warn("更新[{}]用户缓存成功。", staffId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public LoginUserDetailsResultDTO getLoginUserDetails(String app, String client, String staffId) { |
|
|
public LoginUserDetailsResultDTO getLoginUserDetails(String app, String client, String staffId) { |
|
|
return cpUserDetailRedis.get(app, client, staffId, LoginUserDetailsResultDTO.class); |
|
|
return cpUserDetailRedis.get(app, client, staffId, LoginUserDetailsResultDTO.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询角色的操作key对应操作范围列表 |
|
|
|
|
|
* @param roleId |
|
|
|
|
|
* @param operationKey |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public Set<RoleOpeScopeResultDTO> listOperationScopesByRoleId(String roleId, String operationKey) { |
|
|
|
|
|
Set<RoleOpeScopeResultDTO> roleOpeScopes = roleOpeScopeRedis.getRoleOpeScopes(roleId, operationKey); |
|
|
|
|
|
if (roleOpeScopes != null) { |
|
|
|
|
|
return roleOpeScopes; |
|
|
|
|
|
} |
|
|
|
|
|
Set<RoleOpeScopeResultDTO> scopes = operationScopeDao.listOperationScopesByRoleId(roleId, operationKey); |
|
|
|
|
|
try { |
|
|
|
|
|
roleOpeScopeRedis.setRoleOpeScopes(roleId, operationKey, scopes); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
|
|
logger.error("GovAccess:查询角色的操作范围:缓存范围出错:{}", errorStackTrace); |
|
|
|
|
|
} |
|
|
|
|
|
return scopes; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<RoleOpeScopeResultDTO> listAllRoleOperationScopesByRoleId(String roleId) { |
|
|
public List<RoleOpeScopeResultDTO> listAllRoleOperationScopesByRoleId(String roleId) { |
|
|
List<RoleOpeScopeResultDTO> roleAllOpeScopes = roleOpeScopeRedis.getRoleAllOpeScopes(roleId); |
|
|
List<RoleOpeScopeResultDTO> roleAllOpeScopes = roleOpeScopeRedis.getRoleAllOpeScopes(roleId); |
|
|