feat(专区用户权限检测): 当用户为当前专区会员,但是拥有父级组织管理权限时,返回后台管理地址

This commit is contained in:
OTTO 2023-12-22 09:49:54 +08:00
parent 7fabdaf4ab
commit 98bc71f93a
2 changed files with 25 additions and 7 deletions

View File

@ -146,17 +146,23 @@ public class ZoneAsyncServiceImpl implements IZoneAsyncService {
, new ArrayBlockingQueue<>(100)
, Executors.defaultThreadFactory()
, (r, executor) -> {
throw new ServiceException("目前创建的人太多了,请稍后再试");
throw new ServiceException("【%s】目前创建的人太多了,请稍后再试", DateUtils.getNowDate());
}
);
@Override
public void asyncInitZoneData(ZoneDetail zoneDetail) {
System.out.printf("%s:线程【%s】开始处理专区【%s】的首页配置", DateUtils.getNowDate(), Thread.currentThread().getName(), zoneDetail.getName());
threadPoolExecutor.execute(() -> initHomePage(zoneDetail));
System.out.printf("%s:线程【%s】开始处理专区【%s】的文章初始化", DateUtils.getNowDate(), Thread.currentThread().getName(), zoneDetail.getName());
threadPoolExecutor.execute(() -> initCms(zoneDetail));
System.out.printf("%s:线程【%s】开始处理专区【%s】的项目聚合初始化", DateUtils.getNowDate(), Thread.currentThread().getName(), zoneDetail.getName());
threadPoolExecutor.execute(() -> initProject(zoneDetail));
System.out.printf("%s:线程【%s】开始处理专区【%s】的会员聚合初始化", DateUtils.getNowDate(), Thread.currentThread().getName(), zoneDetail.getName());
threadPoolExecutor.execute(() -> initMember(zoneDetail));
System.out.printf("%s:线程【%s】开始处理专区【%s】的合作伙伴初始化", DateUtils.getNowDate(), Thread.currentThread().getName(), zoneDetail.getName());
threadPoolExecutor.execute(() -> initPartners(zoneDetail));
System.out.printf("%s:线程【%s】开始处理专区【%s】的资源聚合初始化", DateUtils.getNowDate(), Thread.currentThread().getName(), zoneDetail.getName());
threadPoolExecutor.execute(() -> initResource(zoneDetail));
}

View File

@ -414,19 +414,26 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
List<SysUserDeptRole> userIdentifyList =
FeignUtils.getReturnData(remoteUserService.getSysUserDeptRoleListByUserName(userName, SecurityConstants.INNER));
if (userIdentifyList != null && !userIdentifyList.isEmpty()) {
// 查找该用户父级组织中的非会员身份
SysUserDeptRole notMemberParentUserIdentify = userIdentifyList.stream()
.filter(x -> !zoneDetail.getDeptId().equals(x.getDeptId())
&& deptAncestors.contains(String.valueOf(x.getDeptId()))
&& (x.getSysRole() != null && !SystemRole.ZONE_MEMBER.getRoleKey().equals(x.getSysRole().getRoleKey())))
.findFirst().orElse(null);
//优先判断该用户是否存在本专区的管理权限若存在则直接切到本专区管理身份便于管理
//切到本专区时前台的后台管理按钮将跳转到首页配置页面
SysUserDeptRole userIdentify = userIdentifyList.stream()
.filter(x -> zoneDetail.getDeptId().equals(x.getDeptId()))
.findFirst().orElse(null);
if(userIdentify!=null){
return genChangeCurrentUserIdentityUrl(userIdentify, gitLinkToken, zoneId);
return genChangeCurrentUserIdentityUrl(userIdentify, gitLinkToken, zoneId, notMemberParentUserIdentify);
}
// 当不存在当前专区对应的管理权限时查找在父级组织中是否存在身份
userIdentify = userIdentifyList.stream()
.filter(x -> deptAncestors.contains(String.valueOf(x.getDeptId())))
.findFirst().orElse(null);
if (userIdentify != null) {
return genChangeCurrentUserIdentityUrl(userIdentify, gitLinkToken, zoneId);
return genChangeCurrentUserIdentityUrl(userIdentify, gitLinkToken, zoneId, notMemberParentUserIdentify);
}
}
return null;
@ -441,20 +448,25 @@ public class ZoneDetailServiceImpl implements IZoneDetailService {
* @param userIdentify
* @param gitLinkToken
* @param zoneId
* @param notMemberParentUserIdentify
* @return
*/
private String genChangeCurrentUserIdentityUrl(SysUserDeptRole userIdentify, String gitLinkToken, Long zoneId) {
private String genChangeCurrentUserIdentityUrl(SysUserDeptRole userIdentify, String gitLinkToken, Long zoneId, SysUserDeptRole notMemberParentUserIdentify) {
String roleKey = userIdentify.getSysRole().getRoleKey();
Long deptId = userIdentify.getDeptId();
remoteUserService.changeCurrentUserIdentity(userIdentify.getDeptId(), SecurityConstants.INNER, gitLinkToken);
if (SystemRole.ZONE_MEMBER.getRoleKey().equals(roleKey)) {
return null;
if (notMemberParentUserIdentify != null) {
roleKey = notMemberParentUserIdentify.getSysRole().getRoleKey();
deptId = notMemberParentUserIdentify.getDeptId();
}
}
if (SystemRole.ZONE_ADMIN.getRoleKey().equals(roleKey)
|| SystemRole.ZONE_OPERATOR.getRoleKey().equals(roleKey)) {
return zoneConfigurationUrl + "?changeCurrentUserIdentity=" + userIdentify.getDeptId();
return zoneConfigurationUrl + "?changeCurrentUserIdentity=" + deptId;
}
if (SystemRole.PLATFORM_ADMIN.getRoleKey().equals(roleKey)) {
return zoneConfigurationUrl + "/" + zoneId + "?changeCurrentUserIdentity=" + userIdentify.getDeptId();
return zoneConfigurationUrl + "/" + zoneId + "?changeCurrentUserIdentity=" + deptId;
}
return null;