浏览代码

fix:补全逻辑,判断角色应仅从RoleList出发

xuexiaobo 6 年之前
父节点
当前提交
58ffd31a93
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6 6
      site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

+ 6 - 6
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -127,7 +127,7 @@ public class WebMediatorImpl implements ViewMediator {
                             BeanUtils.copyProperties(crowdTestProjectPO, project);
                             return new CrowdProjectVO(project);}).collect(Collectors.toList());
         //对于区域管理员
-        if (user.getRegionalManager() != null){
+        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("RegionalManager"))){
             List<CrowdTestProjectPO> crowdTestProjectPOList = projectDao.findByRegionalManagerIdAndIsDeleted(userId, DeletedStatus.isNotDeleted);
             //获取区域管理员正在处理中的项目列表
             myCrowdDTO.setHandlingProjects(crowdTestProjectPOList.stream().filter(crowdTestProjectPO -> crowdTestProjectPO.getStatus()>CrowdTestProjectStatus.HAS_RELEASED).map(crowdTestProjectPO -> {
@@ -152,12 +152,12 @@ public class WebMediatorImpl implements ViewMediator {
         myCrowdDTO.setMyProjects(myProejcts);
         myCrowdDTO.setUserVO(userVO);
 
-        if (user.getEvaluationAgency() == null)
+        if (user.getRoleList().stream().noneMatch(role -> role.getName().equals("evaluationAgency")))
             return myCrowdDTO;
         List<CrowdTestTask> allTaskOfAgency = null;
         List<CrowdTaskVO> unfinishedTasks = null;
         List<CrowdTaskVO> finishedTasks = null;
-        if (user.getEvaluationAgency()!=null) {
+        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("evaluationAgency"))) {
             allTaskOfAgency = taskDao.findByEvaluationAgencyIdAndIsDeleted(user.getEvaluationAgency().getUserId(), 0).stream()
                     .map(crowdTestTaskPO -> {
                         CrowdTestTask task = new CrowdTestTask();
@@ -274,7 +274,7 @@ public class WebMediatorImpl implements ViewMediator {
         UserDTO userDTO = new UserDTO();
         userDTO.setRoleList(user.getRoleList().stream().map(Role::getName).collect(Collectors.toList()));
         userDTO.setUserVO(new UserVO(user));
-        if (user.getEvaluationAgency() != null)
+        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("evaluationAgency")))
             userDTO.setAgencyVO(new AgencyVO(user.getEvaluationAgency()));
         return userDTO;
     }
@@ -317,7 +317,7 @@ public class WebMediatorImpl implements ViewMediator {
             }
         }
         //区域管理员视角
-        if (user.getRegionalManager()!=null){
+        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("RegionalManager"))){
             if ((project.getProjectDistributionTypeId() == 0 && project.getRegionalManagerId().equals(user.getId()))
                     || (project.getProjectDistributionTypeId()>0 && project.getStatus()>=CrowdTestProjectStatus.HAS_RECEIVED && project.getRegionalManagerId().equals(user.getId()))){
                 if (project.getStatus() == CrowdTestProjectStatus.HAS_RELEASED){
@@ -364,7 +364,7 @@ public class WebMediatorImpl implements ViewMediator {
             }
         }
         //评测机构视角
-        if (user.getEvaluationAgency()!=null && task.getStatus()!=CrowdTestTaskStatus.HAS_REJECTED){
+        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("evaluationAgency")) && task.getStatus()!=CrowdTestTaskStatus.HAS_REJECTED){
             if ((task.getDistributionType()==0 && task.getEvaluationAgencyId().equals(user.getId()))
                     ||(task.getDistributionType()==2 && task.getStatus()>=CrowdTestTaskStatus.HAS_RECEIVED && task.getEvaluationAgencyId().equals(user.getId()))){
                 if (task.getStatus()==CrowdTestTaskStatus.HAS_RELEASED){