ソースを参照

修改个人认证操作

guochao 6 年 前
コミット
d08d11eba6

ファイルの差分が大きいため隠しています
+ 0 - 0
core/src/main/java/com/mooctest/crowd/domain/controller/TestUserController.java


+ 4 - 4
core/src/main/java/com/mooctest/crowd/domain/domainobject/CrowdTestProject.java

@@ -276,10 +276,10 @@ public class CrowdTestProject {
      * @return
      */
     public CrowdTestProject createCrowdTestProject(User user) {
-        //判断用户是否认证
-        if(user.getPersonalAuthentication() == null && user.getEnterpriseAuthentication() == null && user.getRegionalManager() == null && user.getEvaluationAgency() == null){
-            throw new CrowdTestProjectException("当前用户未进行认证,无权限对项目操作");
-        }
+//        //判断用户是否认证
+//        if(user.getPersonalAuthentication() == null && user.getEnterpriseAuthentication() == null && user.getRegionalManager() == null && user.getEvaluationAgency() == null){
+//            throw new CrowdTestProjectException("当前用户未进行认证,无权限对项目操作");
+//        }
         //增加设置项目code ---------需要补上
 //        String projectCode = GenerateFlowCodeUtil.generateFlowCode("PROJ");
 //        this.setCode(projectCode);

+ 8 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/EvaluationAgency.java

@@ -47,4 +47,12 @@ public class EvaluationAgency {
                 ", checkTime=" + checkTime +
                 '}';
     }
+
+    public EvaluationAgency applyAuthentication(Long id) {
+        this.setUserId(id);
+        this.setIsAuthentication(AuthenticationStatus.isAuthenIng);
+        this.setIsDeleted(DeletedStatus.isNotDeleted);
+        this.setCreateTime(new Timestamp(System.currentTimeMillis()));
+        return this;
+    }
 }

+ 23 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/PersonalAuthentication.java

@@ -40,4 +40,27 @@ public class PersonalAuthentication {
                 ", checkTime='" + checkTime + '\'' +
                 '}';
     }
+
+    public PersonalAuthentication applyAuthentication(Long userId) {
+        this.setUserId(userId);
+        this.setIsAuthentication(AuthenticationStatus.isAuthenIng);
+        this.setIsDeleted(DeletedStatus.isNotDeleted);
+        this.setApplyTime(new Timestamp(System.currentTimeMillis()));
+        this.setExplain("");
+        return this;
+    }
+
+    public PersonalAuthentication passAuthentication() {
+        this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
+        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+        this.setExplain("");
+        return this;
+    }
+
+    public PersonalAuthentication rejectAuthentication(String explain) {
+        this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
+        this.setExplain(explain);
+        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+        return this;
+    }
 }

+ 28 - 47
core/src/main/java/com/mooctest/crowd/domain/domainobject/User.java

@@ -62,17 +62,9 @@ public class User {
      * @return
      */
     public User applyAgencyAuthentication(EvaluationAgency evaluationAgency) {
-        if (this.getEvaluationAgency()!=null)
-            throw new BaseException("已认证为评测机构,不可重复认证");
-        if (this.getPersonalAuthentication()!=null)
-            throw new BaseException("已实名认证,不可认证为评测机构");
-        if (this.getEnterpriseAuthentication()!=null)
-            throw new BaseException("已认证为企业用户,不可认证为评测机构");
-        evaluationAgency.setUserId(this.id);
-        evaluationAgency.setIsAuthentication(AuthenticationStatus.isAuthenIng);
-        evaluationAgency.setIsDeleted(DeletedStatus.isNotDeleted);
-        evaluationAgency.setCreateTime(new Timestamp(System.currentTimeMillis()));
-        this.setEvaluationAgency(evaluationAgency);
+        if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
+            throw new BaseException("已有认证信息,不可再次认证");
+        this.setEvaluationAgency(evaluationAgency.applyAuthentication(this.id));
         return this;
     }
 
@@ -86,56 +78,45 @@ public class User {
      * 个人实名认证
      * @return
      */
-    public User applyPersonalAuthentication(PersonalAuthentication personalAuthentication) {
-        if (this.getEvaluationAgency()!=null)
-            throw new BaseException("已认证为评测机构,不可认证为个人用户");
-        if (this.getPersonalAuthentication()!=null)
-            throw new BaseException("已实名认证,不可重复认证");
-        if (this.getEnterpriseAuthentication()!=null)
-            throw new BaseException("已认证为企业用户,不可认证为个人用户");
-        personalAuthentication.setUserId(this.id);
-        personalAuthentication.setIsAuthentication(AuthenticationStatus.isAuthenIng);
-        personalAuthentication.setIsDeleted(DeletedStatus.isNotDeleted);
-        personalAuthentication.setApplyTime(new Timestamp(System.currentTimeMillis()));
-        personalAuthentication.setExplain("");
-        this.setPersonalAuthentication(personalAuthentication);
+    public User applyPersonalAuthentication(PersonalAuthentication personalAuth) {
+        if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
+            throw new BaseException("已有认证信息,不可再次认证");
+        this.setPersonalAuthentication(personalAuth.applyAuthentication(this.id));
         return this;
     }
 
+    /**
+     * 同意通过个人认证
+     * @return
+     */
     public User passPersonalAuthApplication() {
-        if(this.getPersonalAuthentication().getIsDeleted() == DeletedStatus.isDeleted){
-            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
+        PersonalAuthentication personalAuth = this.getPersonalAuthentication();
+        if(personalAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
+        }else if(personalAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("当前已通过认证,不可再次进行认证");
         }else{
-            if(this.getPersonalAuthentication().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
-                throw new BaseException("当前是未通过认证状态,不可通过认证");
-            }else if(this.getPersonalAuthentication().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
-                throw new BaseException("当前已通过认证,不可再次进行认证");
-            }else{
-                this.getPersonalAuthentication().setIsAuthentication(AuthenticationStatus.isAuthenticated);
-                this.getPersonalAuthentication().setCheckTime(new Timestamp(System.currentTimeMillis()));
-                this.getPersonalAuthentication().setExplain("");
-                List<Role> roleList = this.getRoleList();
-                Role role = new Role();
-                role.setId(1L);
-                roleList.add(role);
-                this.setRoleList(roleList);
-                return this;
-            }
+            this.setPersonalAuthentication(personalAuth.passAuthentication());
+            return this;
+//            List<Role> roleList = this.getRoleList();
+//            Role role = new Role();
+//            role.setId(1L);
+//            roleList.add(role);
+//            this.setRoleList(roleList);
         }
     }
 
     public User personalAuthFailure(String explain) {
-        if(this.getPersonalAuthentication().getIsDeleted() == DeletedStatus.isDeleted){
+        PersonalAuthentication personalAuth = this.getPersonalAuthentication();
+        if(personalAuth.getIsDeleted() == DeletedStatus.isDeleted){
             throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
         }else {
-            if(this.getPersonalAuthentication().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+            if(personalAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
                 throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
-            }else if(this.getPersonalAuthentication().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            }else if(personalAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
                 throw new BaseException("当前已通过认证,不可拒绝认证");
             }else {
-                this.getPersonalAuthentication().setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
-                this.getPersonalAuthentication().setExplain(explain);
-                this.getPersonalAuthentication().setCheckTime(new Timestamp(System.currentTimeMillis()));
+                this.setPersonalAuthentication(personalAuth.rejectAuthentication(explain));
                 return this;
             }
         }

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません