Browse Source

Merge branch 'feature-V2.0' of ssh://git.mooctest.com:1022/crowd-2019/crowd-test-service-backend into feature-V2.0

guo00guo 5 years ago
parent
commit
044ff4814f

+ 13 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/CrowdTestTask.java

@@ -1,5 +1,6 @@
 package com.mooctest.crowd.domain.domainobject;
 
+import com.mooctest.crowd.domain.exception.BaseException;
 import com.mooctest.crowd.domain.exception.CrowdTestTaskException;
 import com.mooctest.crowd.domain.exception.UnauthorizedException;
 import lombok.Data;
@@ -90,6 +91,18 @@ public class CrowdTestTask {
      * @return
      */
     public void receive(User user){
+        //判断用户是否为接包用户
+    List<Role>  roles=  user.getRoleList();
+    List<String> roleNames=new ArrayList<>();
+    for(int i=0;i<roles.size();i++){
+        roleNames.add(roles.get(i).getName());
+    }
+    if(!roleNames.contains("evaluationUser")&&!roleNames.contains("evaluationAgency")&&!roleNames.contains("RegionalManager")){
+         throw  new BaseException("当前用户没有接包权限");
+    }
+
+
+
         //判断是否为测评机构
         EvaluationAgency evaluationAgency = user.getEvaluationAgency();
         if(evaluationAgency == null){

+ 2 - 2
core/src/main/java/com/mooctest/crowd/domain/repository/UserRepo.java

@@ -133,7 +133,7 @@ public class UserRepo implements IUserRepo {
     }
 
     @Override
-    public ArrayList<UserPO> getAllUserInfo() throws RoleNotFoundException {
+    public ArrayList<UserPO> getAllUserInfo() throws RoleNotFoundException{
         Iterable<UserPO> allUserPO = userDao.findAll();
         ArrayList<UserPO> userPOArrayList = Lists.newArrayList(allUserPO);
         return userPOArrayList;
@@ -349,7 +349,7 @@ public class UserRepo implements IUserRepo {
      * @return
      * @throws RoleNotFoundException
      */
-    private User getUserAndRoleAndPermissionByUserPO(UserPO userPO) throws RoleNotFoundException {
+    private User getUserAndRoleAndPermissionByUserPO(UserPO userPO) throws RoleNotFoundException{
         User userResult = Converter.convert(User.class, userPO);
         List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userResult.getId());
         List<Role> roleResultList = new ArrayList<>();

+ 1 - 0
site/src/main/java/com/mooctest/crowd/site/command/ApplyPersonalAuthCommand.java

@@ -18,6 +18,7 @@ import java.util.*;
 @Data
 public class ApplyPersonalAuthCommand {
 
+    @NotNull(message = "请选择成为接包用户还是发包用户")
     private  List<Integer> roleList;
 
     private String  userId;

File diff suppressed because it is too large
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CommonController.java


+ 2 - 0
site/src/main/java/com/mooctest/crowd/site/controller/CrowdProjectController.java

@@ -41,6 +41,8 @@ public class CrowdProjectController{
      */
     @RequestMapping(value = "/api/project/", method = RequestMethod.POST)
     public ProjectDetailsDTO createProject(@Validated @RequestBody CrowdTestProjectCommand crowdTestProjectCommand, BindingResult result,HttpSession session){
+
+
         long  userId=Long.parseLong((String) session.getAttribute("userId"));
 
         if (result.hasErrors()) {

+ 4 - 4
site/src/main/java/com/mooctest/crowd/site/controller/UserController.java

@@ -35,7 +35,7 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/api")
-public class UserController extends BaseController {
+public class UserController extends BaseController{
     @Autowired
     private PersonalAuthService personalAuthService;
     @Autowired
@@ -146,8 +146,8 @@ public class UserController extends BaseController {
     public PersonalAuthVO applyPersonalAuthentication(@PathVariable("userId") Long userId,
                                                       @Validated @RequestBody ApplyPersonalAuthCommand command,
                                                       BindingResult result, HttpSession session) {
-//        if (!userId.equals(Long.parseLong((String) session.getAttribute("userId"))))
-//            throw new UnauthorizedException("没有权限对他人账号进行操作!");
+        if (!userId.equals(Long.parseLong((String) session.getAttribute("userId"))))
+            throw new UnauthorizedException("没有权限对他人账号进行操作!");
         LOG.info("当前用户申请的认证信息为" + command);
         if (result.hasErrors())
             throw new BaseException(result.getFieldError().getDefaultMessage());
@@ -313,7 +313,7 @@ public class UserController extends BaseController {
      * @return
      */
     @RequestMapping(value = "index/address", method = RequestMethod.GET)
-    public Area getAddressByIp(HttpServletRequest request) throws UnsupportedEncodingException {
+    public Area getAddressByIp(HttpServletRequest request) throws UnsupportedEncodingException{
         String ip = DataUtils.getClientIp(request);
         LOG.info("ip地址是========" + ip);
         Area area = AddressUtils.getProvinceName(ip);

+ 0 - 1
site/src/main/java/com/mooctest/crowd/site/data/vo/CrowdProjectVO.java

@@ -105,6 +105,5 @@ public class CrowdProjectVO implements Serializable {
             this.statusVO.setText("已截止");
             this.statusVO.setStyle("warning");
         }
-
     }
 }

+ 4 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/ResourceVO.java

@@ -1,6 +1,8 @@
 package com.mooctest.crowd.site.data.vo;
 
+import com.mooctest.crowd.domain.domainobject.CrowdTestProjectStatus;
 import com.mooctest.crowd.domain.domainobject.Resource;
+import com.mooctest.crowd.domain.domainobject.ResourceStatus;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -30,6 +32,7 @@ public class ResourceVO implements Serializable {
     private Timestamp startTime;
     private String personnel;
     private String remarks;
+    private StatusVO statusVO;
 
     public ResourceVO(Resource resource){
         code = resource.getCode();
@@ -47,4 +50,5 @@ public class ResourceVO implements Serializable {
         personnel=resource.getPersonnel();
         remarks=resource.getRemarks();
     }
+
 }

+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/mediator/ViewMediator.java

@@ -24,7 +24,7 @@ public interface ViewMediator {
 
     void    saveUserRole(User user, ApplyPersonalAuthCommand command);
 
-    List<UserVO> renderMoreUser(Pageable pageable);
+    List<UserVO> renderMoreUser(Pageable pageable,String keyword);
 
 
     List<CrowdTaskVO> findMoreHotTasks();

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

@@ -154,7 +154,7 @@ public class WebMediatorImpl implements ViewMediator {
     }
 
     @Override
-    public List<UserVO> renderMoreUser(Pageable pageable) {
+    public List<UserVO> renderMoreUser(Pageable pageable,String keyword) {
         //获取众测人员排名
 //        String agencyName = agencyDao.findById(Long.parseLong(agencyId)).get().getEvaluationAgencyName();
 //        List<UserVO> userVOS = taskToUserDao.findTotalCountOfUser().stream().map(rankInfo -> {
@@ -167,17 +167,18 @@ public class WebMediatorImpl implements ViewMediator {
 //            }
 //            return null;
 //        }).filter(Objects::nonNull).collect(Collectors.toList());
-
-
         List<UserVO> userVOS = userTaskCountDao.findByType(RoleType.EVALUATION_USER.getId())
                 .stream().sorted(Comparator.comparing(UserTaskCountPO::getCount)).collect(Collectors.toList())
                 .stream().map(userTaskCountPO -> {
                     User user = userRepo.getByIDJustInfo(userTaskCountPO.getUserId());
                     UserVO userVO = new UserVO(user);
                     userVO.setTaskCount(userTaskCountPO.getCount());
-                    return userVO;
+                       return userVO;
                 }).collect(Collectors.toList());
-        return userVOS;
+        if (keyword != null && keyword.trim() != "") {
+            return  userVOS.stream().filter(userVO -> userVO.getName().contains(keyword)).collect(Collectors.toList());
+        }
+        return  userVOS;
     }
 
     @Override
@@ -1226,6 +1227,20 @@ public class WebMediatorImpl implements ViewMediator {
             resourceVO.setStandard(resourcePO.getStandard());
             resourceVO.setUnit(resourcePO.getUnit());
             resourceVO.setState(resourcePO.getState());
+            StatusVO statusVO = new StatusVO();
+            if(resourcePO.getState()==0){
+                statusVO.setText("空闲");
+                resourceVO.setStatusVO(statusVO);
+            }else if(resourcePO.getState()==1){
+                statusVO.setText("占用");
+                resourceVO.setStatusVO(statusVO);
+            }else if(resourcePO.getState()==2){
+                statusVO.setText("可用");
+                resourceVO.setStatusVO(statusVO);
+            }else if(resourcePO.getState()==3){
+                statusVO.setText("故障");
+                resourceVO.setStatusVO(statusVO);
+            }
             resourceVO.setStartTime(resourcePO.getStartTime());
             resourceVO.setPersonnel(resourcePO.getPersonnel());
             resourceVO.setRemarks(resourcePO.getRemarks());
@@ -1250,14 +1265,20 @@ public class WebMediatorImpl implements ViewMediator {
         resourceVO.setUnitWork(resourcePO.get().getUnitWork());
         resourceVO.setStandard(resourcePO.get().getStandard());
         resourceVO.setUnit(resourcePO.get().getUnit());
-        if (resourcePO.get().getState() == 0) {
-            resourceVO.setState(ResourceStatus.R_FREE);
-        } else if (resourcePO.get().getState() == 1) {
-            resourceVO.setState(ResourceStatus.R_OCCUPY);
-        } else if (resourcePO.get().getState() == 2) {
-            resourceVO.setState(ResourceStatus.R_USABLE);
-        } else {
-            resourceVO.setState(ResourceStatus.R_FAULT);
+        resourceVO.setState(resourcePO.get().getState());
+        StatusVO statusVO = new StatusVO();
+        if(resourcePO.get().getState()==0){
+            statusVO.setText("空闲");
+            resourceVO.setStatusVO(statusVO);
+        }else if(resourcePO.get().getState()==1){
+            statusVO.setText("占用");
+            resourceVO.setStatusVO(statusVO);
+        }else if(resourcePO.get().getState()==2){
+            statusVO.setText("可用");
+            resourceVO.setStatusVO(statusVO);
+        }else if(resourcePO.get().getState()==3){
+            statusVO.setText("故障");
+            resourceVO.setStatusVO(statusVO);
         }
         resourceVO.setStartTime(resourcePO.get().getStartTime());
         resourceVO.setPersonnel(resourcePO.get().getPersonnel());

+ 1 - 1
site/src/main/java/com/mooctest/crowd/site/service/CommonService.java

@@ -14,7 +14,7 @@ import java.util.Map;
 public interface CommonService {
 
 
-    List<UserVO> getMoreUser(Pageable pageable);
+    List<UserVO> getMoreUser(Pageable pageable,String keyword);
 
     IndexDTO getIndexInfo();
 

+ 2 - 2
site/src/main/java/com/mooctest/crowd/site/service/impl/CommonServiceImpl.java

@@ -53,8 +53,8 @@ public class CommonServiceImpl implements CommonService {
 //    private CacheUtil cacheUtil;
 
     @Override
-    public List<UserVO> getMoreUser(Pageable pageable) {
-        return  viewMediator.renderMoreUser(pageable);
+    public List<UserVO> getMoreUser(Pageable pageable,String keyword) {
+        return  viewMediator.renderMoreUser(pageable,keyword);
     }
 
     @Override

+ 1 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/CrowdProjectServiceImpl.java

@@ -157,6 +157,7 @@ public class CrowdProjectServiceImpl implements CrowdProjectService {
                 canCreateProject = true;
             } else {
                 canCreateProject = false;
+                throw new BaseException("用户权限不足无法创建项目");
 
             }
         }

File diff suppressed because it is too large
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/UserServiceImpl.java


Some files were not shown because too many files changed in this diff