use of com.easy.cloud.core.operator.sysresource.pojo.dto.SysResourceDTO 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.sysresource.pojo.dto.SysResourceDTO in project dq-easy-cloud by dq-open-cloud.
the class SysResourceServiceImpl method getPermissionTree.
@Override
public EcBaseServiceResult getPermissionTree() {
SysResourceQuery query = new SysResourceQuery();
query.setAvailable(EcBaseConstant.EcAvailableEnum.YES.type());
List<SysResourceEntity> resourceEntities = sysResourceDAO.listByQuery(query);
List<SysResourceDTO> resourceDTOS = EcJSONUtils.parseArray(resourceEntities, SysResourceDTO.class);
for (SysResourceDTO sysResourceDTO : resourceDTOS) {
for (SysResourceDTO sysResourceDTOTemp : resourceDTOS) {
if (EcBaseUtils.equals(sysResourceDTOTemp.getParentNo(), sysResourceDTO.getResourceNo())) {
sysResourceDTO.getChildren().add(sysResourceDTOTemp);
}
}
}
for (SysResourceDTO sysResourceDTO : resourceDTOS) {
if (sysResourceDTO.getParentNo() == 0) {
return EcBaseServiceResult.newInstanceOfSucResult(sysResourceDTO);
}
}
return EcBaseServiceResult.newInstanceOfSuccess();
}
use of com.easy.cloud.core.operator.sysresource.pojo.dto.SysResourceDTO 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