Procházet zdrojové kódy

add:认证审核拒绝接口

xuexiaobo před 6 roky
rodič
revize
3ef76a8612

+ 2 - 6
core/src/main/java/com/mooctest/crowd/domain/domainobject/EvaluationAgency.java

@@ -62,6 +62,8 @@ public class EvaluationAgency {
     }
 
     public EvaluationAgency passAuthentication() {
+        if (this.getIsAuthentication()==AuthenticationStatus.isAuthenticated)
+            throw new BaseException("该用户已通过认证,请勿重复操作!");
         this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
         this.setCheckTime(new Timestamp(System.currentTimeMillis()));
         this.setExplain("");
@@ -91,10 +93,4 @@ public class EvaluationAgency {
         this.isDeleted = DeletedStatus.isDeleted;
         return this;
     }
-
-    public void passAuthentication(){
-        if (this.getIsAuthentication()==AuthenticationStatus.isAuthenticated)
-            throw new BaseException("该用户已通过认证,请勿重复操作!");
-        this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
-    }
 }

+ 7 - 0
site/src/main/java/com/mooctest/crowd/site/controller/AgencyController.java

@@ -73,6 +73,13 @@ public class AgencyController {
         return agencyService.passAuth(userId, operatorId);
     }
 
+    @LoginRequired
+    @RequestMapping(value = "/user/{userId}/agency/status/reject", method = RequestMethod.PUT)
+    public void rejectAuth(@PathVariable("userId") Long userId, HttpSession session){
+        Long operatorId = Long.parseLong((String)session.getAttribute("userId"));
+        agencyService.rejectAuth(userId, operatorId);
+    }
+
     /**
      * 测评机构修改能力和资源信息
      * @param userId

+ 11 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/AgencyServiceImpl.java

@@ -122,5 +122,16 @@ public class AgencyServiceImpl implements AgencyService {
         return mediator.renderUser(userRepo.saveUser(user));
     }
 
+    @Override
+    public void rejectAuth(Long userId, Long operatorId) {
+        User operator = userRepo.getByID(operatorId);
+        if (operator.getRoleList().stream().noneMatch(role -> role.getName().equals("SystemAdministrator")))
+            throw new UnauthorizedException("无权限进行此操作");
+        User user = userRepo.getByID(userId);
+        if (user.getEvaluationAgency() == null)
+            throw new BaseException("该用户未申请机构认证!");
+        user.getEvaluationAgency().rejectAuthentication("");
+    }
+
 
 }