forked from Gitlink/microservices
feat(超算专区): 检查当前登录用户在当前专区下权限异常问题
This commit is contained in:
parent
6982b6451d
commit
d631abe3a1
|
|
@ -20,6 +20,9 @@ public class ZoneFrontRoleVo {
|
|||
@ApiModelProperty(value = "资讯管理访问地址")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private String docManageUrl;
|
||||
@ApiModelProperty(value = "项目管理访问地址")
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private String projectManageUrl;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.microservices.system.api.RemoteUserService;
|
|||
import com.microservices.system.api.domain.SysDept;
|
||||
import com.microservices.system.api.domain.SysDictData;
|
||||
import com.microservices.system.api.domain.SysUserDeptRole;
|
||||
import com.microservices.system.api.model.LoginUser;
|
||||
import com.microservices.system.api.utils.FeignUtils;
|
||||
import com.microservices.zone.common.service.IZoneAsyncService;
|
||||
import com.microservices.zone.detail.domain.ZoneDetail;
|
||||
|
|
@ -108,14 +109,19 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
private IZoneSpecialProjectService zoneSpecialProjectService;
|
||||
@Value("${zone.zoneAdminUrl}")
|
||||
private String zoneAdminUrl;
|
||||
@Value("${zone.zoneConfigurationUrl}")
|
||||
private String zoneConfigurationUrl;
|
||||
@Value("${zone.zoneConfigurationPath:/zone/configuration}")
|
||||
private String zoneConfigurationPath;
|
||||
@Value("${zone.adminUrl}")
|
||||
private String adminUrl;
|
||||
@Value("${zone.resourceManageUrl}")
|
||||
private String resourceManageUrl;
|
||||
@Value("${zone.docManageUrl}")
|
||||
private String docManageUrl;
|
||||
@Value("${zone.resourceManagePath:/zone/resource/resource}")
|
||||
private String resourceManagePath;
|
||||
@Value("${zone.docManagePath:/zone/content/doc}")
|
||||
private String docManagePath;
|
||||
@Value("${zone.projectManagePath:/zone/project/list}")
|
||||
private String projectManagePath;
|
||||
|
||||
@Value("${http.gatewayUrl}")
|
||||
public String gatewayUrl;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
|
@ -202,13 +208,13 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
Date[] lastWeek = getLastWeek();
|
||||
//专区文章数统计
|
||||
ZoneDetailDataVo articlesGroupByKey = zoneDetailMapper
|
||||
.countArticlesGroupByKey(lastWeek[0],lastWeek[1],zoneDetail.getKey()) ;
|
||||
.countArticlesGroupByKey(lastWeek[0], lastWeek[1], zoneDetail.getKey());
|
||||
if (articlesGroupByKey != null) {
|
||||
zoneDetailDataVo.setWeekArticles(articlesGroupByKey.getWeekArticles());
|
||||
}
|
||||
//专区浏览数据统计
|
||||
ZoneDetailDataVo puVsGroupByKey = zoneDetailMapper
|
||||
.countPUVsGroupByKey(lastWeek[0],lastWeek[1],zoneDetail.getKey()) ;
|
||||
.countPUVsGroupByKey(lastWeek[0], lastWeek[1], zoneDetail.getKey());
|
||||
if (puVsGroupByKey != null) {
|
||||
zoneDetailDataVo.setWeekPV(puVsGroupByKey.getWeekPV());
|
||||
zoneDetailDataVo.setWeekUV(puVsGroupByKey.getWeekUV());
|
||||
|
|
@ -505,14 +511,14 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
.filter(x -> zoneDetail.getDeptId().equals(x.getDeptId()))
|
||||
.findFirst().orElse(null);
|
||||
if (userIdentify != null) {
|
||||
return genChangeCurrentUserIdentityUrl(userIdentify, gitLinkToken, zoneId, notMemberParentUserIdentify);
|
||||
return genChangeCurrentUserIdentityUrl(userIdentify, zoneId, notMemberParentUserIdentify);
|
||||
}
|
||||
// 当不存在当前专区对应的管理权限时查找在父级组织中是否存在身份
|
||||
userIdentify = userIdentifyList.stream()
|
||||
.filter(x -> deptAncestors.contains(String.valueOf(x.getDeptId())))
|
||||
.findFirst().orElse(null);
|
||||
if (userIdentify != null) {
|
||||
return genChangeCurrentUserIdentityUrl(userIdentify, gitLinkToken, zoneId, notMemberParentUserIdentify);
|
||||
return genChangeCurrentUserIdentityUrl(userIdentify, zoneId, notMemberParentUserIdentify);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -525,12 +531,11 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
* <a href="https://www.gitlink.org.cn/Gitlink/forgeplus/issues/3523">参照需求</a>
|
||||
*
|
||||
* @param userIdentify
|
||||
* @param gitLinkToken
|
||||
* @param zoneId
|
||||
* @param notMemberParentUserIdentify
|
||||
* @return
|
||||
*/
|
||||
private String genChangeCurrentUserIdentityUrl(SysUserDeptRole userIdentify, String gitLinkToken, Long zoneId, SysUserDeptRole notMemberParentUserIdentify) {
|
||||
private String genChangeCurrentUserIdentityUrl(SysUserDeptRole userIdentify, Long zoneId, SysUserDeptRole notMemberParentUserIdentify) {
|
||||
String roleKey = userIdentify.getSysRole().getRoleKey();
|
||||
Long deptId = userIdentify.getDeptId();
|
||||
if (SystemRole.ZONE_MEMBER.getRoleKey().equals(roleKey)) {
|
||||
|
|
@ -541,10 +546,10 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
}
|
||||
if (SystemRole.ZONE_ADMIN.getRoleKey().equals(roleKey)
|
||||
|| SystemRole.ZONE_OPERATOR.getRoleKey().equals(roleKey)) {
|
||||
return zoneConfigurationUrl + "?changeCurrentUserIdentity=" + deptId;
|
||||
return gatewayUrl + zoneConfigurationPath + "?changeCurrentUserIdentity=" + deptId;
|
||||
}
|
||||
if (SystemRole.PLATFORM_ADMIN.getRoleKey().equals(roleKey)) {
|
||||
return zoneConfigurationUrl + "/" + zoneId + "?changeCurrentUserIdentity=" + deptId;
|
||||
return gatewayUrl + zoneConfigurationPath + "/" + zoneId + "?changeCurrentUserIdentity=" + deptId;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -635,19 +640,48 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
public ZoneFrontRoleVo checkCurrentRoleInZone(Long zoneId) {
|
||||
ZoneFrontRoleVo zoneFrontRoleVo = new ZoneFrontRoleVo();
|
||||
ZoneDetail zoneDetail = selectZoneDetailById(zoneId);
|
||||
boolean isZoneAdmin = AuthUtil.hasUserIdentity(zoneDetail.getDeptId(), SystemRole.ZONE_ADMIN.getRoleKey());
|
||||
boolean isZoneOperator = AuthUtil.hasUserIdentity(zoneDetail.getDeptId(), SystemRole.ZONE_OPERATOR.getRoleKey());
|
||||
boolean isZoneMember = AuthUtil.hasUserIdentity(zoneDetail.getDeptId(), SystemRole.ZONE_MEMBER.getRoleKey());
|
||||
if (isZoneAdmin || isZoneOperator) {
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_MANAGER);
|
||||
zoneFrontRoleVo.setResourceManageUrl(resourceManageUrl);
|
||||
zoneFrontRoleVo.setDocManageUrl(docManageUrl);
|
||||
} else if (isZoneMember) {
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_MEMBER);
|
||||
} else {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysDept sysDept = FeignUtils.getReturnData(remoteDeptService.getDeptByDeptId(zoneDetail.getDeptId(), SecurityConstants.INNER));
|
||||
List<SysUserDeptRole> userIdentifyList = FeignUtils.getReturnData(
|
||||
remoteUserService.getSysUserDeptRoleListByUserName(loginUser.getUsername(), SecurityConstants.INNER)
|
||||
);
|
||||
if (sysDept == null || userIdentifyList == null) {
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_NONE);
|
||||
return zoneFrontRoleVo;
|
||||
} else {
|
||||
List<String> deptIdList = Arrays.asList(sysDept.getAncestors().split(","));
|
||||
SysUserDeptRole parentDeptUserIdentify = userIdentifyList
|
||||
.stream()
|
||||
.filter(x -> deptIdList.contains(String.valueOf(x.getDeptId())))
|
||||
.filter(x -> !x.getSysRole().getRoleKey().equals(SystemRole.ZONE_MEMBER.getRoleKey()))
|
||||
.findFirst().orElse(null);
|
||||
SysUserDeptRole currentUserIdentify = userIdentifyList.stream().filter(x -> x.getDeptId().equals(zoneDetail.getDeptId())).findFirst().orElse(null);
|
||||
String resourceManageUrl = gatewayUrl + resourceManagePath + "?changeCurrentUserIdentity=";
|
||||
String docManageUrl = gatewayUrl + docManagePath + "?changeCurrentUserIdentity=";
|
||||
String projectManageUrl = gatewayUrl + projectManagePath + "?changeCurrentUserIdentity=";
|
||||
if (currentUserIdentify != null) {
|
||||
if (currentUserIdentify.getSysRole().getRoleKey().equals(SystemRole.ZONE_MEMBER.getRoleKey())) {
|
||||
if (parentDeptUserIdentify != null) {
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_MANAGER);
|
||||
zoneFrontRoleVo.setResourceManageUrl(resourceManageUrl + parentDeptUserIdentify.getDeptId());
|
||||
zoneFrontRoleVo.setDocManageUrl(docManageUrl + parentDeptUserIdentify.getDeptId());
|
||||
zoneFrontRoleVo.setProjectManageUrl(projectManageUrl + parentDeptUserIdentify.getDeptId());
|
||||
return zoneFrontRoleVo;
|
||||
} else {
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_MEMBER);
|
||||
return zoneFrontRoleVo;
|
||||
}
|
||||
} else {
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_MANAGER);
|
||||
zoneFrontRoleVo.setResourceManageUrl(resourceManageUrl + currentUserIdentify.getDeptId());
|
||||
zoneFrontRoleVo.setDocManageUrl(docManageUrl + currentUserIdentify.getDeptId());
|
||||
zoneFrontRoleVo.setProjectManageUrl(projectManageUrl + currentUserIdentify.getDeptId());
|
||||
return zoneFrontRoleVo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zoneFrontRoleVo.setRole(ZoneConstants.FRONT_ROLE_NONE);
|
||||
return zoneFrontRoleVo;
|
||||
}
|
||||
|
||||
|
|
@ -678,14 +712,14 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
|
|||
}
|
||||
if (SystemRole.ZONE_ADMIN.getRoleKey().equals(roleKey)
|
||||
|| SystemRole.ZONE_OPERATOR.getRoleKey().equals(roleKey)) {
|
||||
return zoneConfigurationUrl;
|
||||
return gatewayUrl + zoneConfigurationPath;
|
||||
}
|
||||
if (SystemRole.PLATFORM_ADMIN.getRoleKey().equals(roleKey)) {
|
||||
ZoneDetail zoneDetail = zoneDetailMapper.selectZoneDetailByDeptId(deptId);
|
||||
if (zoneDetail == null) {
|
||||
return zoneAdminUrl;
|
||||
}
|
||||
return zoneConfigurationUrl + "/" + zoneDetail.getId();
|
||||
return gatewayUrl + zoneConfigurationPath + "/" + zoneDetail.getId();
|
||||
}
|
||||
|
||||
return adminUrl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue