use of com.easy.cloud.core.operator.sysrole.pojo.dto.SysRoleDTO in project dq-easy-cloud by dq-open-cloud.
the class EcAuthorityRealm method doGetAuthorizationInfo.
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
EcAuthorityUserDTO<Long> authorityUserDTO = (EcAuthorityUserDTO) principals.getPrimaryPrincipal();
List<SysRoleDTO> roleList = sysRoleService.findByUserId(authorityUserDTO.getAuthorityUserId());
Set<Integer> roleNos = new HashSet<>();
for (SysRoleDTO role : roleList) {
authorizationInfo.addRole(role.getName());
roleNos.add(role.getRoleNo());
}
List<SysResourceDTO> roleResourceDTOs = sysResourceService.findByRoleNos(new ArrayList<>(roleNos));
for (SysResourceDTO resourceDTO : roleResourceDTOs) {
authorizationInfo.addStringPermission(resourceDTO.getPermission());
}
return authorizationInfo;
}
use of com.easy.cloud.core.operator.sysrole.pojo.dto.SysRoleDTO in project dq-easy-cloud by dq-open-cloud.
the class SysResourceServiceImpl method listPermissionOfCurrentUser.
@Override
public EcBaseServiceResult listPermissionOfCurrentUser() {
Subject subject = SecurityUtils.getSubject();
SysUserDTO sysUserDTO = (SysUserDTO) subject.getPrincipal();
List<SysRoleDTO> roles = sysRoleService.findByUserId(sysUserDTO.getId());
Set<Integer> roleNos = new HashSet<>();
for (SysRoleDTO roleDTO : roles) {
roleNos.add(roleDTO.getRoleNo());
}
List<SysResourceDTO> resourceDTOS = findByRoleNos(new ArrayList<>(roleNos));
return EcBaseServiceResult.newInstanceOfSucResult(resourceDTOS);
}
Aggregations