Procházet zdrojové kódy

会议列表增加角色控制的数据权限

master
WendyYang před 1 rokem
rodič
revize
c2974a2650
6 změnil soubory, kde provedl 109 přidání a 13 odebrání
  1. +24
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/model/entity/ViewRegionDTO.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java
  3. +4
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java
  4. +3
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java
  5. +66
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingDataScopeHelper.java
  6. +11
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java

+ 24
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/model/entity/ViewRegionDTO.java Zobrazit soubor

@@ -0,0 +1,24 @@
package com.ningdatech.pmapi.common.model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Collection;

/**
* <p>
* ViewRegionDTO
* </p>
*
* @author WendyYang
* @since 2023/4/27
**/
@Data
@AllArgsConstructor
public class ViewRegionDTO {

private Collection<String> regions;

private Integer regionLevel;

}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java Zobrazit soubor

@@ -34,7 +34,7 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider {
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.COMPANY_MANAGER);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

}

+ 4
- 3
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java Zobrazit soubor

@@ -13,9 +13,10 @@ import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;

/**
* <p>
@@ -46,11 +47,11 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider {
}

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList()));
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.REGION_MANAGER);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

}

+ 3
- 3
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java Zobrazit soubor

@@ -12,9 +12,9 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;

/**
* <p>
@@ -41,11 +41,11 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider {
RegionConst.RL_CITY);

DataScopeDTO ds = new DataScopeDTO();
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList()));
ds.setRegionCodes(new ArrayList<>(regionCodes));
ds.setUserId(userFullInfo.getUserId());
ds.setEmployeeCode(userFullInfo.getEmployeeCode());
ds.setRole(RoleEnum.SUPER_ADMIN);
return Optional.ofNullable(ds);
return Optional.of(ds);
}

}

+ 66
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingDataScopeHelper.java Zobrazit soubor

@@ -0,0 +1,66 @@
package com.ningdatech.pmapi.meeting.helper;

import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.model.entity.ViewRegionDTO;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
* <p>
* MeetingDataScopeHelper
* </p>
*
* @author WendyYang
* @since 2023/4/27
**/
@Component
@AllArgsConstructor
public class MeetingDataScopeHelper {

private final RegionCacheHelper regionCacheHelper;

private static RoleEnum getRolePriorityMax() {
List<Role> roleList = LoginUserUtil.loginUserDetail().getUserRoleList();
List<String> roleCodeList = CollUtils.fieldList(roleList, Role::getCode);
if (roleCodeList.contains(RoleEnum.SUPER_ADMIN.name())) {
return RoleEnum.SUPER_ADMIN;
}
if (roleCodeList.contains(RoleEnum.REGION_MANAGER.name())) {
return RoleEnum.REGION_MANAGER;
}
return RoleEnum.EXPERT_ADMIN;
}

public ViewRegionDTO meetingListViewRegions() {
RoleEnum role = getRolePriorityMax();
UserInfoDetails user = LoginUserUtil.loginUserDetail();
String regionCode = user.getRegionCode();
Integer regionLevel = user.getRegionLevel();
Collection<String> regions;
switch (role) {
case SUPER_ADMIN:
regions = null;
break;
case REGION_MANAGER:
regions = regionCacheHelper.listChildRegionCodeList(regionCode, regionLevel);
break;
case EXPERT_ADMIN:
regions = Collections.singletonList(regionCode);
break;
default:
regions = Collections.emptyList();
break;
}
return new ViewRegionDTO(regions, regionLevel);
}

}

+ 11
- 6
pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java Zobrazit soubor

@@ -19,9 +19,9 @@ import com.ningdatech.basic.util.StrPool;
import com.ningdatech.basic.util.ValidUtil;
import com.ningdatech.cache.lock.DistributedLock;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.model.entity.ViewRegionDTO;
import com.ningdatech.pmapi.expert.constant.ReviewResultEnum;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.helper.PermissionCheckHelper;
import com.ningdatech.pmapi.expert.model.entity.ExpertReview;
import com.ningdatech.pmapi.expert.service.IExpertReviewService;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
@@ -36,8 +36,8 @@ import com.ningdatech.pmapi.meeting.entity.req.*;
import com.ningdatech.pmapi.meeting.entity.vo.*;
import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper;
import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper;
import com.ningdatech.pmapi.meeting.helper.MeetingDataScopeHelper;
import com.ningdatech.pmapi.meeting.helper.MeetingManageHelper;
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper;
import com.ningdatech.pmapi.meeting.service.*;
import com.ningdatech.pmapi.meeting.task.ExpertRandomInviteTask;
import com.ningdatech.pmapi.meta.helper.DictionaryCache;
@@ -87,9 +87,7 @@ public class MeetingManage {
private final ExpertInviteManage expertInviteManage;
private final ExpertRandomInviteTask expertRandomInviteTask;
private final MeetingManageHelper meetingManageHelper;
private final YxtCallOrSmsHelper yxtCallOrSmsHelper;
private final DistributedLock distributedLock;
private final PermissionCheckHelper permissionCheckHelper;
private final IProjectService projectService;
private final IMeetingInnerProjectService meetingInnerProjectService;
private final IMeetingOuterProjectService meetingOuterProjectService;
@@ -98,6 +96,7 @@ public class MeetingManage {
private final IExpertReviewService expertReviewService;
private final ExpertInviteHelper expertInviteHelper;
private final MeetingCallOrMsgHelper meetingCallOrMsgHelper;
private final MeetingDataScopeHelper meetingDataScopeHelper;
private static final String INVITED_RULE_CREATE = "INVITED_RULE_CREATE:";

private static final String MEETING_CREATE_KEY = "MEETING_CREATE:";
@@ -388,11 +387,17 @@ public class MeetingManage {
* @author WendyYang
*/
public PageVo<MeetingByManagerVO> meetingListForManager(MeetingListReq req) {
ViewRegionDTO viewRegions = meetingDataScopeHelper.meetingListViewRegions();
Collection<String> regions;
if ((regions = viewRegions.getRegions()) != null && regions.isEmpty()) {
return PageVo.empty();
}
LambdaQueryWrapper<Meeting> query = new LambdaQueryWrapper<Meeting>()
.orderByDesc(Meeting::getCreateOn);
// 补充逻辑 如果拥有超级管理员权限可以看到所有事务
if (!permissionCheckHelper.isSuperAdmin()) {
query.eq(Meeting::getCreateBy, LoginUserUtil.getUserId());
if (regions != null) {
query.in(Meeting::getRegionCode, regions);
query.ge(Meeting::getRegionLevel, viewRegions.getRegionLevel());
}
query.eq(req.getStatus() != null, Meeting::getStatus, req.getStatus());
meetingManageHelper.buildMeetingQuery(query, req);


Načítá se…
Zrušit
Uložit