Bladeren bron

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

xuexiaobo 6 jaren geleden
bovenliggende
commit
8287aa0e99

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


+ 2 - 0
core/src/main/java/com/mooctest/crowd/domain/dao/EnterpriseAuthenticationDao.java

@@ -17,6 +17,8 @@ public interface EnterpriseAuthenticationDao extends PagingAndSortingRepository<
 
     EnterpriseAuthenticationPO findByUserId(Long userId);
 
+    EnterpriseAuthenticationPO findByUserIdAndIsDeleted(Long Id, int deletedStatus);
+
     List<EnterpriseAuthenticationPO> findAll();
 
     EnterpriseAuthenticationPO save(EnterpriseAuthenticationPO enterpriseAuthenticationPO);

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

@@ -0,0 +1,84 @@
+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;
+    }
+}

+ 42 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/EnterpriseAuthentication.java

@@ -1,6 +1,7 @@
 package com.mooctest.crowd.domain.domainobject;
 
 import lombok.Data;
+import org.springframework.beans.BeanUtils;
 
 import java.sql.Timestamp;
 
@@ -43,4 +44,45 @@ public class EnterpriseAuthentication {
                 ", checkTime='" + checkTime + '\'' +
                 '}';
     }
+
+    public EnterpriseAuthentication 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 EnterpriseAuthentication passAuthentication() {
+        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;
+    }
+
+    public EnterpriseAuthentication updateAuthInfo(EnterpriseAuthentication 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 EnterpriseAuthentication deleteAuth() {
+        this.isDeleted = DeletedStatus.isDeleted;
+        return this;
+    }
 }

+ 39 - 5
core/src/main/java/com/mooctest/crowd/domain/domainobject/EvaluationAgency.java

@@ -3,6 +3,7 @@ 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;
 
 import java.sql.Timestamp;
 import java.util.List;
@@ -26,8 +27,8 @@ public class EvaluationAgency {
     private int isDeleted;
     private Timestamp updateTime;
     private Timestamp expireTime;
-    private Timestamp createTime;
     private Timestamp checkTime;
+    private Timestamp applyTime;
 
     @Override
     public String toString() {
@@ -45,16 +46,49 @@ public class EvaluationAgency {
                 ", isDeleted=" + isDeleted +
                 ", updateTime=" + updateTime +
                 ", expireTime=" + expireTime +
-                ", createTime=" + createTime +
+                ", applyTime=" + applyTime +
                 ", checkTime=" + checkTime +
                 '}';
     }
 
-    public EvaluationAgency applyAuthentication(Long id) {
-        this.setUserId(id);
+    public EvaluationAgency applyAuthentication(Long userId) {
+        this.setUserId(userId);
         this.setIsAuthentication(AuthenticationStatus.isAuthenIng);
         this.setIsDeleted(DeletedStatus.isNotDeleted);
-        this.setCreateTime(new Timestamp(System.currentTimeMillis()));
+        this.setApplyTime(new Timestamp(System.currentTimeMillis()));
+        this.setCheckTime(null);
+        this.setExplain("");
+        return this;
+    }
+
+    public EvaluationAgency passAuthentication() {
+        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;
+    }
+
+    public EvaluationAgency updateAuthInfo(EvaluationAgency 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 EvaluationAgency deleteAuth() {
+        this.isDeleted = DeletedStatus.isDeleted;
         return this;
     }
 

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

@@ -60,7 +60,7 @@ public class User {
     }
 
     /**
-     * 机构认证
+     * 机构认证——申请
      * @param evaluationAgency
      * @return
      */
@@ -71,14 +71,80 @@ public class User {
         return this;
     }
 
-    public User passApplication() {
-        this.getEvaluationAgency().setIsAuthentication(AuthenticationStatus.isAuthenticated);
-        this.getEvaluationAgency().setCheckTime(new Timestamp(System.currentTimeMillis()));
+
+    /**
+     * 机构认证——通过
+     * @return
+     */
+    public User passAgencyAuthApplication(User agencyUser) {
+        //判断是否为系统管理员
+        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;
+        }
+    }
+
+    /**
+     * 机构认证——驳回,并说明驳回原因
+     * @param explain
+     * @return
+     */
+    public User rejectAgencyAuth(User agencyUser, String explain) {
+        //判断是否为系统管理员
+        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;
+            }
+        }
+    }
+
+    /**
+     * 机构认证——信息修改
+     * @param modifyAuth
+     * @return
+     */
+    public User updateAgencyAuthInfo(EvaluationAgency modifyAuth){
+        if (this.getEnterpriseAuthentication()!=null || this.getPersonalAuthentication()!=null)
+            throw new BaseException("已有其他认证信息,不可对认证未企业用户");
+
+        this.getEvaluationAgency().updateAuthInfo(modifyAuth);
         return this;
     }
 
     /**
-     * 个人实名认证
+     * 机构认证——删除
+     * @return
+     */
+    public User deleteAgencyAuthInfo() {
+        this.getEvaluationAgency().deleteAuth();
+        return this;
+    }
+
+
+    /**
+     * 个人认证——申请
      * @return
      */
     public User applyPersonalAuthentication(PersonalAuthentication personalAuth) {
@@ -89,14 +155,12 @@ public class User {
     }
 
     /**
-     * 同意通过个人认证
+     * 个人认证——通过
      * @return
      */
     public User passPersonalAuthApplication(User personalUser) {
         //判断是否为系统管理员
-        if(this.getSystemAdministratorToUser() == null){
-            throw new SystemAdministratorException("当前用户不是系统管理员,没有权限进行认证审核操作");
-        }
+        judgeIsSystemAdministrator();
 
         PersonalAuthentication personalAuth = personalUser.getPersonalAuthentication();
         if(personalAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
@@ -115,15 +179,13 @@ public class User {
     }
 
     /**
-     * 驳回个人认证,并说明驳回原因
+     * 个人认证——驳回,并说明驳回原因
      * @param explain
      * @return
      */
-    public User personalAuthFailure(User personalUser, String explain) {
+    public User personalAuthReject(User personalUser, String explain) {
         //判断是否为系统管理员
-        if(this.getSystemAdministratorToUser() == null){
-            throw new SystemAdministratorException("当前用户不是系统管理员,没有权限进行认证审核操作");
-        }
+        judgeIsSystemAdministrator();
 
         PersonalAuthentication personalAuth = personalUser.getPersonalAuthentication();
         if(personalAuth.getIsDeleted() == DeletedStatus.isDeleted){
@@ -141,19 +203,112 @@ public class User {
     }
 
     /**
-     * 修改个人认证信息
+     * 个人认证——信息修改
      * @param modifyAuth
      * @return
      */
     public User updatePersonalAuthInfo(PersonalAuthentication modifyAuth){
         if (this.getEvaluationAgency()!=null || this.getEnterpriseAuthentication()!=null)
             throw new BaseException("已有其他认证信息,不可对个人认证进行操作");
+
         this.getPersonalAuthentication().updateAuthInfo(modifyAuth);
         return this;
     }
 
+    /**
+     * 个人认证——删除
+     * @return
+     */
     public User deletePersonalAuthInfo() {
         this.getPersonalAuthentication().deleteAuth();
         return this;
     }
+
+    /**
+     * 企业认证——申请
+     * @return
+     */
+    public User applyEnterpriseAuthentication(EnterpriseAuthentication enterpriseAuth) {
+        if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
+            throw new BaseException("已有认证信息,不可再次认证");
+        this.setEnterpriseAuthentication(enterpriseAuth.applyAuthentication(this.id));
+        return this;
+    }
+
+    /**
+     * 企业认证——通过
+     * @return
+     */
+    public User passEnterpriseAuthApplication(User enterpriseUser) {
+        //判断是否为系统管理员
+        judgeIsSystemAdministrator();
+
+        EnterpriseAuthentication enterpriseAuth = enterpriseUser.getEnterpriseAuthentication();
+        if(enterpriseAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+            throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
+        }else if(enterpriseAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("当前已通过认证,不可再次进行认证");
+        }else{
+            enterpriseAuth.passAuthentication();
+            List<Role> roleList = this.getRoleList();
+            Role role = new Role();
+            role.setId(5L);
+            roleList.add(role);
+            enterpriseUser.setRoleList(roleList);
+            return enterpriseUser;
+        }
+    }
+
+    /**
+     * 企业认证——驳回,并说明驳回原因
+     * @param explain
+     * @return
+     */
+    public User enterpriseAuthReject(User enterpriseUser, String explain) {
+        //判断是否为系统管理员
+        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;
+            }
+        }
+    }
+
+    /**
+     * 企业认证——修改
+     * @param modifyAuth
+     * @return
+     */
+    public User updateEnterpriseAuthInfo(EnterpriseAuthentication modifyAuth){
+        if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null)
+            throw new BaseException("已有其他认证信息,不可对认证未企业用户");
+
+        this.getEnterpriseAuthentication().updateAuthInfo(modifyAuth);
+        return this;
+    }
+
+    /**
+     * 企业认证——删除
+     * @return
+     */
+    public User deleteEnterpriseAuthInfo() {
+        this.getEnterpriseAuthentication().deleteAuth();
+        return this;
+    }
+
+    //判断是否为系统管理员
+    private void judgeIsSystemAdministrator(){
+        if(this.getSystemAdministratorToUser() == null){
+            throw new SystemAdministratorException("当前用户不是系统管理员,没有权限进行认证审核操作");
+        }
+    }
 }

+ 15 - 15
core/src/main/java/com/mooctest/crowd/domain/model/EnterpriseAuthenticationPO.java

@@ -15,43 +15,43 @@ import java.sql.Timestamp;
 public class EnterpriseAuthenticationPO {
 
     @Id
-    @Column(name = "CA_ID")
+    @Column(name = "EA_ID")
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
 
-    @Column(name = "CA_USER_ID")
+    @Column(name = "EA_USER_ID")
     private Long userId;
 
-    @Column(name = "CA_ENTERPRISE_NAME")
+    @Column(name = "EA_ENTERPRISE_NAME")
     private String enterpriseName;
 
-    @Column(name = "CA_LEGAL_PERSON_NAME")
+    @Column(name = "EA_LEGAL_PERSON_NAME")
     private String legalPersonName;
 
-    @Column(name = "CA_BUSINESS_LICENSE_PHOTO")
+    @Column(name = "EA_BUSINESS_LICENSE_PHOTO")
     private String businessLicensePhoto;
 
-    @Column(name = "CA_UNIFIED_SOCIAL_CREDIT_CODE")
+    @Column(name = "EA_UNIFIED_SOCIAL_CREDIT_CODE")
     private String unifiedSocialCreditCode;
 
-    @Column(name = "CA_BANK_ACCOUNT")
+    @Column(name = "EA_BANK_ACCOUNT")
     private String bankAccount;
 
-    @Column(name = "CA_ADDRESS")
+    @Column(name = "EA_ADDRESS")
     private String address;
 
-    @Column(name = "CA_IS_DELETED")
+    @Column(name = "EA_IS_DELETED")
     private int isDeleted;
 
-    @Column(name = "CA_IS_AUTHENTICATION")
+    @Column(name = "EA_IS_AUTHENTICATION")
     private int isAuthentication;
 
-    @Column(name = "CA_NOT_PASS_EXPLAIN")
+    @Column(name = "EA_NOT_PASS_EXPLAIN")
     private String explain;
 
-    @Column(name = "CA_APPLY_TIME")
-    private Timestamp applyTime;
-
-    @Column(name = "CA_CHECK_TIME")
+    @Column(name = "EA_CHECK_TIME")
     private Timestamp checkTime;
+
+    @Column(name = "EA_APPLY_TIME")
+    private Timestamp applyTime;
 }

+ 8 - 8
core/src/main/java/com/mooctest/crowd/domain/model/EvaluationAgencyPO.java

@@ -33,6 +33,12 @@ public class EvaluationAgencyPO{
     @Column(name = "EA_PHOTO")
     private String agencyPhoto;
 
+    @Column(name = "EA_UPDATE_TIME")
+    private Timestamp updateTime;
+
+    @Column(name = "EA_EXPIRE_TIME")
+    private Timestamp expireTime;
+
     @Column(name = "EA_IS_AUTHENTICATION")
     private int isAuthentication;
 
@@ -42,14 +48,8 @@ public class EvaluationAgencyPO{
     @Column(name = "EA_IS_DELETED")
     private int isDeleted;
 
-    @Column(name = "EA_UPDATE_TIME")
-    private Timestamp updateTime;
-
-    @Column(name = "EA_EXPIRE_TIME")
-    private Timestamp expireTime;
-
-    @Column(name = "EA_CREATE_TIME")
-    private Timestamp createTime;
+    @Column(name = "EA_APPLY_TIME")
+    private Timestamp applyTime;
 
     @Column(name = "EA_CHECK_TIME")
     private Timestamp checkTime;

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

@@ -365,6 +365,12 @@ public class UserRepo implements IUserRepo {
             userResult.setPersonalAuthentication(Converter.convert(PersonalAuthentication.class, personalAuthenticationPO));
         }
 
+        /*获取企业认证的信息*/
+        EnterpriseAuthenticationPO enterpriseAuthenticationPO = enterpriseAuthenticationDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
+        if(enterpriseAuthenticationPO != null){
+            userResult.setEnterpriseAuthentication(Converter.convert(EnterpriseAuthentication.class, enterpriseAuthenticationPO));
+        }
+
         /*获取区域管理员信息*/
         List<RegionalManagerPO> regionalManagerPOList = regionalManagerDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
         if(regionalManagerPOList.size() > 0){

+ 1 - 1
core/src/test/java/com/mooctest/crowd/domain/domainobject/CrowdTestProjectTest.java

@@ -158,7 +158,7 @@ public class CrowdTestProjectTest {
         evaluationAgency.setIsAuthentication(AuthenticationStatus.isAuthenticated);
         evaluationAgency.setExpireTime(user.getCreateTime());
         evaluationAgency.setUpdateTime(user.getCreateTime());
-        evaluationAgency.setCreateTime(user.getCreateTime());
+        evaluationAgency.setApplyTime(user.getCreateTime());
 
         evaluationAgencyAbility.setId(1L);
         evaluationAgencyAbility.setAbilityName("IOS");

+ 1 - 1
core/src/test/java/com/mooctest/crowd/domain/domainobject/UserTest.java

@@ -74,7 +74,7 @@ public class UserTest {
         evaluationAgency.setIsAuthentication(AuthenticationStatus.isAuthenticated);
         evaluationAgency.setExpireTime(user.getCreateTime());
         evaluationAgency.setUpdateTime(user.getCreateTime());
-        evaluationAgency.setCreateTime(user.getCreateTime());
+        evaluationAgency.setApplyTime(user.getCreateTime());
 
         evaluationAgencyAbility.setId(1L);
         evaluationAgencyAbility.setAbilityName("IOS");

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