@@ -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; | |||||
} |
@@ -34,7 +34,7 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider { | |||||
ds.setUserId(userFullInfo.getUserId()); | ds.setUserId(userFullInfo.getUserId()); | ||||
ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ||||
ds.setRole(RoleEnum.COMPANY_MANAGER); | ds.setRole(RoleEnum.COMPANY_MANAGER); | ||||
return Optional.ofNullable(ds); | |||||
return Optional.of(ds); | |||||
} | } | ||||
} | } |
@@ -13,9 +13,10 @@ import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.util.ArrayList; | |||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Optional; | import java.util.Optional; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -46,11 +47,11 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider { | |||||
} | } | ||||
DataScopeDTO ds = new DataScopeDTO(); | DataScopeDTO ds = new DataScopeDTO(); | ||||
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList())); | |||||
ds.setRegionCodes(new ArrayList<>(regionCodes)); | |||||
ds.setUserId(userFullInfo.getUserId()); | ds.setUserId(userFullInfo.getUserId()); | ||||
ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ||||
ds.setRole(RoleEnum.REGION_MANAGER); | ds.setRole(RoleEnum.REGION_MANAGER); | ||||
return Optional.ofNullable(ds); | |||||
return Optional.of(ds); | |||||
} | } | ||||
} | } |
@@ -12,9 +12,9 @@ import lombok.RequiredArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.util.ArrayList; | |||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Optional; | import java.util.Optional; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
@@ -41,11 +41,11 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider { | |||||
RegionConst.RL_CITY); | RegionConst.RL_CITY); | ||||
DataScopeDTO ds = new DataScopeDTO(); | DataScopeDTO ds = new DataScopeDTO(); | ||||
ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList())); | |||||
ds.setRegionCodes(new ArrayList<>(regionCodes)); | |||||
ds.setUserId(userFullInfo.getUserId()); | ds.setUserId(userFullInfo.getUserId()); | ||||
ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ds.setEmployeeCode(userFullInfo.getEmployeeCode()); | ||||
ds.setRole(RoleEnum.SUPER_ADMIN); | ds.setRole(RoleEnum.SUPER_ADMIN); | ||||
return Optional.ofNullable(ds); | |||||
return Optional.of(ds); | |||||
} | } | ||||
} | } |
@@ -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); | |||||
} | |||||
} |
@@ -19,9 +19,9 @@ import com.ningdatech.basic.util.StrPool; | |||||
import com.ningdatech.basic.util.ValidUtil; | import com.ningdatech.basic.util.ValidUtil; | ||||
import com.ningdatech.cache.lock.DistributedLock; | import com.ningdatech.cache.lock.DistributedLock; | ||||
import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | 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.constant.ReviewResultEnum; | ||||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | 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.model.entity.ExpertReview; | ||||
import com.ningdatech.pmapi.expert.service.IExpertReviewService; | import com.ningdatech.pmapi.expert.service.IExpertReviewService; | ||||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | 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.entity.vo.*; | ||||
import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | ||||
import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper; | 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.MeetingManageHelper; | ||||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||||
import com.ningdatech.pmapi.meeting.service.*; | import com.ningdatech.pmapi.meeting.service.*; | ||||
import com.ningdatech.pmapi.meeting.task.ExpertRandomInviteTask; | import com.ningdatech.pmapi.meeting.task.ExpertRandomInviteTask; | ||||
import com.ningdatech.pmapi.meta.helper.DictionaryCache; | import com.ningdatech.pmapi.meta.helper.DictionaryCache; | ||||
@@ -87,9 +87,7 @@ public class MeetingManage { | |||||
private final ExpertInviteManage expertInviteManage; | private final ExpertInviteManage expertInviteManage; | ||||
private final ExpertRandomInviteTask expertRandomInviteTask; | private final ExpertRandomInviteTask expertRandomInviteTask; | ||||
private final MeetingManageHelper meetingManageHelper; | private final MeetingManageHelper meetingManageHelper; | ||||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||||
private final DistributedLock distributedLock; | private final DistributedLock distributedLock; | ||||
private final PermissionCheckHelper permissionCheckHelper; | |||||
private final IProjectService projectService; | private final IProjectService projectService; | ||||
private final IMeetingInnerProjectService meetingInnerProjectService; | private final IMeetingInnerProjectService meetingInnerProjectService; | ||||
private final IMeetingOuterProjectService meetingOuterProjectService; | private final IMeetingOuterProjectService meetingOuterProjectService; | ||||
@@ -98,6 +96,7 @@ public class MeetingManage { | |||||
private final IExpertReviewService expertReviewService; | private final IExpertReviewService expertReviewService; | ||||
private final ExpertInviteHelper expertInviteHelper; | private final ExpertInviteHelper expertInviteHelper; | ||||
private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; | private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; | ||||
private final MeetingDataScopeHelper meetingDataScopeHelper; | |||||
private static final String INVITED_RULE_CREATE = "INVITED_RULE_CREATE:"; | private static final String INVITED_RULE_CREATE = "INVITED_RULE_CREATE:"; | ||||
private static final String MEETING_CREATE_KEY = "MEETING_CREATE:"; | private static final String MEETING_CREATE_KEY = "MEETING_CREATE:"; | ||||
@@ -388,11 +387,17 @@ public class MeetingManage { | |||||
* @author WendyYang | * @author WendyYang | ||||
*/ | */ | ||||
public PageVo<MeetingByManagerVO> meetingListForManager(MeetingListReq req) { | 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>() | LambdaQueryWrapper<Meeting> query = new LambdaQueryWrapper<Meeting>() | ||||
.orderByDesc(Meeting::getCreateOn); | .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()); | query.eq(req.getStatus() != null, Meeting::getStatus, req.getStatus()); | ||||
meetingManageHelper.buildMeetingQuery(query, req); | meetingManageHelper.buildMeetingQuery(query, req); | ||||