Pārlūkot izejas kodu

修改机构认证DO下的状态判断

guochao 6 gadi atpakaļ
vecāks
revīzija
9fd1f133e8

+ 0 - 84
core/src/main/java/com/mooctest/crowd/domain/domainobject/AuthenticationInfo.java

@@ -1,84 +0,0 @@
-package com.mooctest.crowd.domain.domainobject;
-
-import lombok.Data;
-import org.springframework.beans.BeanUtils;
-
-import java.sql.Timestamp;
-
-/**
- * @author guochao
- * @date 2019-08-26 15:07
- */
-@Data
-public class AuthenticationInfo {
-    private Long id;
-    private Long userId;
-//    private String realName;
-//    private String IDCard;
-//    private String IDCardPhoto;
-    private String bankAccount;
-    private String address;
-    private int isDeleted;
-    private int isAuthentication;
-    private String explain;
-    private Timestamp applyTime;
-    private Timestamp checkTime;
-
-    @Override
-    public String toString() {
-        return "PersonalAuth{" +
-                "id=" + id +
-                ", userId=" + userId +
-//                ", realName='" + realName + '\'' +
-//                ", IDCard='" + IDCard + '\'' +
-//                ", IDCardPhoto='" + IDCardPhoto + '\'' +
-                ", bankAccount='" + bankAccount + '\'' +
-                ", address='" + address + '\'' +
-                ", isAuthentication='" + isAuthentication + '\'' +
-                ", explain=" + explain +
-                ", applyTime='" + applyTime + '\'' +
-                ", checkTime='" + checkTime + '\'' +
-                '}';
-    }
-
-    public AuthenticationInfo applyAuthentication(Long userId) {
-        this.setUserId(userId);
-        this.setIsAuthentication(AuthenticationStatus.isAuthenIng);
-        this.setIsDeleted(DeletedStatus.isNotDeleted);
-        this.setApplyTime(new Timestamp(System.currentTimeMillis()));
-        this.setCheckTime(null);
-        this.setExplain("");
-        return this;
-    }
-
-    public AuthenticationInfo passAuthentication() {
-        this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
-        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
-        this.setExplain("");
-        return this;
-    }
-
-    public AuthenticationInfo rejectAuthentication(String explain) {
-        this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
-        this.setExplain(explain);
-        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
-        return this;
-    }
-
-    public AuthenticationInfo updateAuthInfo(AuthenticationInfo modifyAuth) {
-        modifyAuth.userId = this.userId;
-        modifyAuth.id = this.id;
-        BeanUtils.copyProperties(modifyAuth,this);
-        this.setIsAuthentication(AuthenticationStatus.isAuthenIng);
-        this.setIsDeleted(DeletedStatus.isNotDeleted);
-        this.setApplyTime(new Timestamp(System.currentTimeMillis()));
-        this.setCheckTime(null);
-        this.setExplain("");
-        return this;
-    }
-
-    public AuthenticationInfo deleteAuth() {
-        this.isDeleted = DeletedStatus.isDeleted;
-        return this;
-    }
-}

+ 26 - 8
core/src/main/java/com/mooctest/crowd/domain/domainobject/EnterpriseAuthentication.java

@@ -1,5 +1,6 @@
 package com.mooctest.crowd.domain.domainobject;
 
+import com.mooctest.crowd.domain.exception.BaseException;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
 
@@ -56,17 +57,34 @@ public class EnterpriseAuthentication {
     }
 
     public EnterpriseAuthentication passAuthentication() {
-        this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
-        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
-        this.setExplain("");
-        return this;
+        if(this.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
+        }else if(this.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("当前已通过认证,不可再次进行认证");
+        }else{
+            this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
+            this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+            this.setExplain("");
+            return this;
+        }
+
     }
 
     public EnterpriseAuthentication rejectAuthentication(String explain) {
-        this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
-        this.setExplain(explain);
-        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
-        return this;
+        if(this.getIsDeleted() == DeletedStatus.isDeleted){
+            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
+        }else {
+            if(this.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
+            }else if(this.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+                throw new BaseException("当前已通过认证,不可拒绝认证");
+            }else {
+                this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
+                this.setExplain(explain);
+                this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+                return this;
+            }
+        }
     }
 
     public EnterpriseAuthentication updateAuthInfo(EnterpriseAuthentication modifyAuth) {

+ 25 - 11
core/src/main/java/com/mooctest/crowd/domain/domainobject/EvaluationAgency.java

@@ -1,7 +1,6 @@
 package com.mooctest.crowd.domain.domainobject;
 
 import com.mooctest.crowd.domain.exception.BaseException;
-import com.mooctest.crowd.domain.factory.UserFactory;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
 
@@ -62,19 +61,34 @@ 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("");
-        return this;
+        if(this.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
+        }else if(this.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("当前已通过认证,不可再次进行认证");
+        }else{
+            this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
+            this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+            this.setExplain("");
+            return this;
+        }
+
     }
 
     public EvaluationAgency rejectAuthentication(String explain) {
-        this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
-        this.setExplain(explain);
-        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
-        return this;
+        if(this.getIsDeleted() == DeletedStatus.isDeleted){
+            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
+        }else {
+            if(this.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
+            }else if(this.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+                throw new BaseException("当前已通过认证,不可拒绝认证");
+            }else {
+                this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
+                this.setExplain(explain);
+                this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+                return this;
+            }
+        }
     }
 
     public EvaluationAgency updateAuthInfo(EvaluationAgency modifyAuth) {

+ 26 - 8
core/src/main/java/com/mooctest/crowd/domain/domainobject/PersonalAuthentication.java

@@ -1,5 +1,6 @@
 package com.mooctest.crowd.domain.domainobject;
 
+import com.mooctest.crowd.domain.exception.BaseException;
 import lombok.Data;
 import org.springframework.beans.BeanUtils;
 
@@ -53,17 +54,34 @@ public class PersonalAuthentication {
     }
 
     public PersonalAuthentication passAuthentication() {
-        this.setIsAuthentication(AuthenticationStatus.isAuthenticated);
-        this.setCheckTime(new Timestamp(System.currentTimeMillis()));
-        this.setExplain("");
-        return this;
+        if(this.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
+        }else if(this.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("当前已通过认证,不可再次进行认证");
+        }else{
+            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;
+        if(this.getIsDeleted() == DeletedStatus.isDeleted){
+            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
+        }else {
+            if(this.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
+            }else if(this.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+                throw new BaseException("当前已通过认证,不可拒绝认证");
+            }else {
+                this.setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
+                this.setExplain(explain);
+                this.setCheckTime(new Timestamp(System.currentTimeMillis()));
+                return this;
+            }
+        }
     }
 
     public PersonalAuthentication updateAuthInfo(PersonalAuthentication modifyAuth) {

+ 15 - 58
core/src/main/java/com/mooctest/crowd/domain/domainobject/User.java

@@ -84,19 +84,13 @@ public class User {
         judgeIsSystemAdministrator();
 
         EvaluationAgency evaluationAgency = agencyUser.getEvaluationAgency();
-        if(evaluationAgency.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
-            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
-        }else if(evaluationAgency.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
-            throw new BaseException("当前已通过认证,不可再次进行认证");
-        }else{
-            evaluationAgency.passAuthentication();
-            List<Role> roleList = this.getRoleList();
-            Role role = new Role();
-            role.setId(2L);
-            roleList.add(role);
-            agencyUser.setRoleList(roleList);
-            return agencyUser;
-        }
+        evaluationAgency.passAuthentication();
+        List<Role> roleList = this.getRoleList();
+        Role role = new Role();
+        role.setId(2L);
+        roleList.add(role);
+        agencyUser.setRoleList(roleList);
+        return agencyUser;
     }
 
     /**
@@ -109,19 +103,8 @@ public class User {
         judgeIsSystemAdministrator();
 
         EvaluationAgency evaluationAgency = agencyUser.getEvaluationAgency();
-        if(evaluationAgency.getIsDeleted() == DeletedStatus.isDeleted){
-            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
-        }else {
-            if(evaluationAgency.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
-                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
-            }else if(evaluationAgency.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
-                throw new BaseException("当前已通过认证,不可拒绝认证");
-            }else {
-                evaluationAgency.rejectAuthentication(explain);
-                return agencyUser;
-            }
-        }
-
+        evaluationAgency.rejectAuthentication(explain);
+        return agencyUser;
     }
 
     /**
@@ -175,14 +158,8 @@ public class User {
         judgeIsSystemAdministrator();
 
         PersonalAuthentication personalAuth = personalUser.getPersonalAuthentication();
-        if(personalAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
-            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
-        }else if(personalAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
-            throw new BaseException("当前已通过认证,不可再次进行认证");
-        }else{
-            personalAuth.passAuthentication();
-            return personalUser;
-        }
+        personalAuth.passAuthentication();
+        return personalUser;
     }
 
     /**
@@ -195,18 +172,8 @@ public class User {
         judgeIsSystemAdministrator();
 
         PersonalAuthentication personalAuth = personalUser.getPersonalAuthentication();
-        if(personalAuth.getIsDeleted() == DeletedStatus.isDeleted){
-            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
-        }else {
-            if(personalAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
-                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
-            }else if(personalAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
-                throw new BaseException("当前已通过认证,不可拒绝认证");
-            }else {
-                personalAuth.rejectAuthentication(explain);
-                return personalUser;
-            }
-        }
+        personalAuth.rejectAuthentication(explain);
+        return personalUser;
     }
 
     /**
@@ -281,18 +248,8 @@ public class User {
         judgeIsSystemAdministrator();
 
         EnterpriseAuthentication enterpriseAuth = enterpriseUser.getEnterpriseAuthentication();
-        if(enterpriseAuth.getIsDeleted() == DeletedStatus.isDeleted){
-            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
-        }else {
-            if(enterpriseAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
-                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
-            }else if(enterpriseAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
-                throw new BaseException("当前已通过认证,不可拒绝认证");
-            }else {
-                enterpriseAuth.rejectAuthentication(explain);
-                return enterpriseUser;
-            }
-        }
+        enterpriseAuth.rejectAuthentication(explain);
+        return enterpriseUser;
     }
 
     /**