Commit 2f732dea by huangjinxin

fix:超管返回所有组织权限

1 parent bb6a2582
...@@ -7,6 +7,11 @@ package com.dituhui.pea.order.enums; ...@@ -7,6 +7,11 @@ package com.dituhui.pea.order.enums;
public enum OrganizationType { public enum OrganizationType {
/** /**
* 超管
*/
admin("admin"),
/**
* 大区 * 大区
*/ */
cluster("cluster"), cluster("cluster"),
......
...@@ -181,64 +181,76 @@ public class OrganizationServiceImpl implements OrganizationService { ...@@ -181,64 +181,76 @@ public class OrganizationServiceImpl implements OrganizationService {
.setTitle(orgClusterEntity.getName()); .setTitle(orgClusterEntity.getName());
} }
@Override @Override
public List<OrganizationDTO> getAllOrganizations(String levelType, List<String> organizationIds) { public List<OrganizationDTO> getAllOrganizations(String levelType, List<String> organizationIds) {
log.info("{} {}", levelType, organizationIds); log.info("{} {}", levelType, organizationIds);
switch (OrganizationType.valueOf(levelType)) { switch (OrganizationType.valueOf(levelType)) {
case cluster: case cluster:
List<OrgClusterEntity> clusters = orgClusterDao.findByClusterIdIn(organizationIds); List<OrgClusterEntity> clusters = orgClusterDao.findByClusterIdIn(organizationIds);
if (CollectionUtils.isNotEmpty(clusters)) { if (CollectionUtils.isNotEmpty(clusters)) {
return clusters.stream().map(c -> { return clusters.stream().map(c -> {
OrganizationDTO organizationDTO = new OrganizationDTO(); OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setId(c.getClusterId()); organizationDTO.setId(c.getClusterId());
organizationDTO.setName(c.getName()); organizationDTO.setName(c.getName());
organizationDTO.setType(OrganizationType.cluster.getValue()); organizationDTO.setType(OrganizationType.cluster.getValue());
return organizationDTO; return organizationDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
break; break;
case branch: case branch:
List<OrgBranchEntity> branchs = orgBranchDao.findByBranchIdIn(organizationIds); List<OrgBranchEntity> branchs = orgBranchDao.findByBranchIdIn(organizationIds);
if (CollectionUtils.isNotEmpty(branchs)) { if (CollectionUtils.isNotEmpty(branchs)) {
return branchs.stream().map(c -> { return branchs.stream().map(c -> {
OrganizationDTO organizationDTO = new OrganizationDTO(); OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setId(c.getBranchId()); organizationDTO.setId(c.getBranchId());
organizationDTO.setName(c.getBranchName()); organizationDTO.setName(c.getBranchName());
organizationDTO.setType(OrganizationType.branch.getValue()); organizationDTO.setType(OrganizationType.branch.getValue());
return organizationDTO; return organizationDTO;
} }
).collect(Collectors.toList()); ).collect(Collectors.toList());
} }
break; break;
case group: case group:
List<OrgGroupEntity> groups = orgGroupDao.findByGroupIdIn(organizationIds); List<OrgGroupEntity> groups = orgGroupDao.findByGroupIdIn(organizationIds);
if (CollectionUtils.isNotEmpty(groups)) { if (CollectionUtils.isNotEmpty(groups)) {
return groups.stream().map(c -> { return groups.stream().map(c -> {
OrganizationDTO organizationDTO = new OrganizationDTO(); OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setId(c.getGroupId()); organizationDTO.setId(c.getGroupId());
organizationDTO.setName(c.getGroupName()); organizationDTO.setName(c.getGroupName());
organizationDTO.setType(OrganizationType.group.getValue()); organizationDTO.setType(OrganizationType.group.getValue());
return organizationDTO; return organizationDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
break; break;
case team: case team:
List<OrgTeamEntity> teams = orgTeamDao.findByTeamIdIn(organizationIds); List<OrgTeamEntity> teams = orgTeamDao.findByTeamIdIn(organizationIds);
if (CollectionUtils.isNotEmpty(teams)) { if (CollectionUtils.isNotEmpty(teams)) {
return teams.stream().map(c -> { return teams.stream().map(c -> {
OrganizationDTO organizationDTO = new OrganizationDTO(); OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setId(c.getTeamId()); organizationDTO.setId(c.getTeamId());
organizationDTO.setName(c.getTeamName()); organizationDTO.setName(c.getTeamName());
organizationDTO.setType(OrganizationType.team.getValue()); organizationDTO.setType(OrganizationType.team.getValue());
return organizationDTO; return organizationDTO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
break; break;
default: case admin:
break; List<OrgClusterEntity> adminCluster = orgClusterDao.findAll();
} if (CollectionUtils.isNotEmpty(adminCluster)) {
return Lists.newArrayList(); return adminCluster.stream().map(c -> {
} OrganizationDTO organizationDTO = new OrganizationDTO();
organizationDTO.setId(c.getClusterId());
organizationDTO.setName(c.getName());
organizationDTO.setType(OrganizationType.cluster.getValue());
return organizationDTO;
}).collect(Collectors.toList());
}
break;
default:
break;
}
return Lists.newArrayList();
}
} }
...@@ -183,13 +183,22 @@ public class UserService { ...@@ -183,13 +183,22 @@ public class UserService {
//用户组织机构从关联表获取 //用户组织机构从关联表获取
List<OrganizationDTO> allOrgs = new ArrayList<>(); List<OrganizationDTO> allOrgs = new ArrayList<>();
List<UserOrgEntity> byUserId = userOrgDao.findByUserId(userDTO.getId());
if (CollectionUtils.isNotEmpty(byUserId)) { // 超管处理,不用配置资源自动拥有所有权限
List<String> collect = byUserId.stream().map(UserOrgEntity::getOrgId).collect(Collectors.toList()); if (ids.contains(Globals.SUPER_ADMIN_ID)) {
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations(LevelUtils.convertOrgLevel(byUserId.get(0).getOrgLevel()), collect); Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations("admin", Arrays.asList("admin"));
if (StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) { if (StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) {
allOrgs = result.getResult(); allOrgs = result.getResult();
} }
} else {
List<UserOrgEntity> byUserId = userOrgDao.findByUserId(userDTO.getId());
if (CollectionUtils.isNotEmpty(byUserId)) {
List<String> collect = byUserId.stream().map(UserOrgEntity::getOrgId).collect(Collectors.toList());
Result<List<OrganizationDTO>> result = organizationService.getAllOrganizations(LevelUtils.convertOrgLevel(byUserId.get(0).getOrgLevel()), collect);
if (StringUtils.equals(ResultEnum.SUCCESS.getCode(), result.getCode())) {
allOrgs = result.getResult();
}
}
} }
if (CollectionUtils.isNotEmpty(allOrgs)) { if (CollectionUtils.isNotEmpty(allOrgs)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!