Explorar o código

增加申请个人认证、通过和拒绝认证请求操作

guochao %!s(int64=6) %!d(string=hai) anos
pai
achega
090275bc8b

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
core/src/main/java/com/mooctest/crowd/domain/controller/TestUserController.java


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

@@ -11,12 +11,12 @@ import java.util.Optional;
 @Transactional
 public interface CompanyAuthDao extends PagingAndSortingRepository<CompanyAuthPO, Long>, JpaSpecificationExecutor<CompanyAuthPO> {
 
+    Optional<CompanyAuthPO> findByIdAndIsDeleted(Long Id, int deletedStatus);
+
     Optional<CompanyAuthPO> findById(Long Id);
 
     CompanyAuthPO findByUserId(Long userId);
 
-    List<CompanyAuthPO> findByStatus(int status);
-
     List<CompanyAuthPO> findAll();
 
     CompanyAuthPO save(CompanyAuthPO companyAuthPO);

+ 3 - 1
core/src/main/java/com/mooctest/crowd/domain/dao/PersonalAuthDao.java

@@ -13,9 +13,11 @@ public interface PersonalAuthDao extends PagingAndSortingRepository<PersonalAuth
 
     Optional<PersonalAuthPO> findById(Long Id);
 
+    Optional<PersonalAuthPO> findByIdAndIsDeleted(Long Id, int deletedStatus);
+
     PersonalAuthPO findByUserId(Long userId);
 
-    List<PersonalAuthPO> findByStatus(int status);
+    PersonalAuthPO findByUserIdAndIsDeleted(Long userId, int deletedStatus);
 
     List<PersonalAuthPO> findAll();
 

+ 6 - 7
core/src/main/java/com/mooctest/crowd/domain/domainobject/CompanyAuth.java

@@ -19,7 +19,9 @@ public class CompanyAuth {
     private String unifiedSocialCreditCode;
     private String bankAccount;
     private String address;
-    private int status;
+    private int isDeleted;
+    private int isAuthentication;
+    private String explain;
     private Timestamp applyTime;
     private Timestamp checkTime;
 
@@ -34,14 +36,11 @@ public class CompanyAuth {
                 ", unifiedSocialCreditCode='" + unifiedSocialCreditCode + '\'' +
                 ", bankAccount='" + bankAccount + '\'' +
                 ", address='" + address + '\'' +
-                ", status=" + status +
+                ", isDeleted=" + isDeleted +
+                ", isAuthentication=" + isAuthentication +
+                ", explain=" + explain +
                 ", applyTime='" + applyTime + '\'' +
                 ", checkTime='" + checkTime + '\'' +
                 '}';
     }
-
-    public CompanyAuth applyAuth(){
-        this.status = AuthenticationStatus.isAuthenIng;
-        return this;
-    }
 }

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

@@ -20,10 +20,12 @@ public class EvaluationAgency {
     private List<EvaluationAgencyResource> evaluationAgencyResourceList;
     private String agencyPhoto;
     private int isAuthentication;
+    private String explain;
     private int isDeleted;
     private Timestamp updateTime;
     private Timestamp expireTime;
     private Timestamp createTime;
+    private Timestamp checkTime;
 
     @Override
     public String toString() {
@@ -33,14 +35,16 @@ public class EvaluationAgency {
                 ", evaluationAgencyName='" + evaluationAgencyName + '\'' +
                 ", bankAccount='" + bankAccount + '\'' +
                 ", address='" + address + '\'' +
-                ", evaluationAgencyAbilityList='" + evaluationAgencyAbilityList + '\'' +
-                ", evaluationAgencyResourceList='" + evaluationAgencyResourceList + '\'' +
+                ", evaluationAgencyAbilityList=" + evaluationAgencyAbilityList +
+                ", evaluationAgencyResourceList=" + evaluationAgencyResourceList +
                 ", agencyPhoto='" + agencyPhoto + '\'' +
                 ", isAuthentication=" + isAuthentication +
+                ", explain='" + explain + '\'' +
                 ", isDeleted=" + isDeleted +
                 ", updateTime=" + updateTime +
                 ", expireTime=" + expireTime +
                 ", createTime=" + createTime +
+                ", checkTime=" + checkTime +
                 '}';
     }
 }

+ 5 - 7
core/src/main/java/com/mooctest/crowd/domain/domainobject/PersonalAuth.java

@@ -18,7 +18,9 @@ public class PersonalAuth {
     private String IDCardPhoto;
     private String bankAccount;
     private String address;
-    private int status;
+    private int isDeleted;
+    private int isAuthentication;
+    private String explain;
     private Timestamp applyTime;
     private Timestamp checkTime;
 
@@ -32,14 +34,10 @@ public class PersonalAuth {
                 ", IDCardPhoto='" + IDCardPhoto + '\'' +
                 ", bankAccount='" + bankAccount + '\'' +
                 ", address='" + address + '\'' +
-                ", status='" + status + '\'' +
+                ", isAuthentication='" + isAuthentication + '\'' +
+                ", explain=" + explain +
                 ", applyTime='" + applyTime + '\'' +
                 ", checkTime='" + checkTime + '\'' +
                 '}';
     }
-
-    public PersonalAuth applyAuth(){
-        this.status = AuthenticationStatus.isAuthenIng;
-        return this;
-    }
 }

+ 67 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/User.java

@@ -28,6 +28,8 @@ public class User {
 
     private RegionalManager regionalManager;
     private EvaluationAgency evaluationAgency;
+    private PersonalAuth personalAuth;
+    private CompanyAuth companyAuth;
     private List<Role> roleList;
 
     @Override
@@ -48,6 +50,8 @@ public class User {
                 ", createTime=" + createTime +
                 ", regionalManager=" + regionalManager +
                 ", evaluationAgency=" + evaluationAgency +
+                ", personalAuth=" + personalAuth +
+                ", companyAuth=" + companyAuth +
                 ", roleList=" + roleList +
                 '}';
     }
@@ -161,15 +165,78 @@ public class User {
     public User applyAgencyAuthentication(EvaluationAgency evaluationAgency) {
         if (this.getEvaluationAgency()!=null)
             throw new BaseException("已认证为评测机构,不可重复认证");
+        if (this.getPersonalAuth()!=null)
+            throw new BaseException("已实名认证,不可认证为评测机构");
+        if (this.getCompanyAuth()!=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);
         return this;
     }
 
     public User passApplication() {
         this.getEvaluationAgency().setIsAuthentication(AuthenticationStatus.isAuthenticated);
+        this.getEvaluationAgency().setCheckTime(new Timestamp(System.currentTimeMillis()));
         return this;
     }
+
+    /**
+     * 个人实名认证
+     * @return
+     */
+    public User applyPersonalAuthentication(PersonalAuth personalAuth) {
+        if (this.getEvaluationAgency()!=null)
+            throw new BaseException("已认证为评测机构,不可认证为个人用户");
+        if (this.getPersonalAuth()!=null)
+            throw new BaseException("已实名认证,不可重复认证");
+        if (this.getCompanyAuth()!=null)
+            throw new BaseException("已认证为企业用户,不可认证为个人用户");
+        personalAuth.setUserId(this.id);
+        personalAuth.setIsAuthentication(AuthenticationStatus.isAuthenIng);
+        personalAuth.setIsDeleted(DeletedStatus.isNotDeleted);
+        personalAuth.setApplyTime(new Timestamp(System.currentTimeMillis()));
+        this.setPersonalAuth(personalAuth);
+        return this;
+    }
+
+    public User passPersonalAuthApplication() {
+        if(this.getPersonalAuth().getIsDeleted() == DeletedStatus.isDeleted){
+            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
+        }else{
+            if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+                throw new BaseException("当前是未通过认证状态,不可通过认证");
+            }else if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+                throw new BaseException("当前已通过认证,不可再次进行认证");
+            }else{
+                this.getPersonalAuth().setIsAuthentication(AuthenticationStatus.isAuthenticated);
+                this.getPersonalAuth().setCheckTime(new Timestamp(System.currentTimeMillis()));
+                List<Role> roleList = this.getRoleList();
+                Role role = new Role();
+                role.setId(1L);
+                roleList.add(role);
+                this.setRoleList(roleList);
+                return this;
+            }
+        }
+    }
+
+    public User personalAuthFailure(String explain) {
+        if(this.getPersonalAuth().getIsDeleted() == DeletedStatus.isDeleted){
+            throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
+        }else {
+            if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
+                throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
+            }else if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+                throw new BaseException("当前已通过认证,不可拒绝认证");
+            }else {
+                this.getPersonalAuth().setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
+                this.getPersonalAuth().setExplain(explain);
+                this.getPersonalAuth().setCheckTime(new Timestamp(System.currentTimeMillis()));
+                return this;
+            }
+        }
+    }
 }

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

@@ -40,29 +40,18 @@ public class CompanyAuthPO {
     @Column(name = "CA_ADDRESS")
     private String address;
 
-    @Column(name = "CA_STATUS")
-    private int status;
+    @Column(name = "CA_IS_DELETED")
+    private int isDeleted;
+
+    @Column(name = "CA_IS_AUTHENTICATION")
+    private int isAuthentication;
+
+    @Column(name = "CA_NOT_PASS_EXPLAIN")
+    private String explain;
 
     @Column(name = "CA_APPLY_TIME")
     private Timestamp applyTime;
 
     @Column(name = "CA_CHECK_TIME")
     private Timestamp checkTime;
-
-    @Override
-    public String toString() {
-        return "CompanyAuth{" +
-                "id=" + id +
-                ", userId=" + userId +
-                ", companyName='" + companyName + '\'' +
-                ", legalPersonName='" + legalPersonName + '\'' +
-                ", businessLicensePhoto='" + businessLicensePhoto + '\'' +
-                ", unifiedSocialCreditCode='" + unifiedSocialCreditCode + '\'' +
-                ", bankAccount='" + bankAccount + '\'' +
-                ", address='" + address + '\'' +
-                ", status=" + status +
-                ", applyTime='" + applyTime + '\'' +
-                ", checkTime='" + checkTime + '\'' +
-                '}';
-    }
 }

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

@@ -36,6 +36,9 @@ public class EvaluationAgencyPO{
     @Column(name = "EA_IS_AUTHENTICATION")
     private int isAuthentication;
 
+    @Column(name = "EA_NOT_PASS_EXPLAIN")
+    private String explain;
+
     @Column(name = "EA_IS_DELETED")
     private int isDeleted;
 
@@ -48,20 +51,6 @@ public class EvaluationAgencyPO{
     @Column(name = "EA_CREATE_TIME")
     private Timestamp createTime;
 
-    @Override
-    public String toString() {
-        return "EvaluationAgencyPO{" +
-                "id=" + id +
-                ", userId=" + userId +
-                ", evaluationAgencyName='" + evaluationAgencyName + '\'' +
-                ", bankAccount='" + bankAccount + '\'' +
-                ", address='" + address + '\'' +
-                ", agencyPhoto='" + agencyPhoto + '\'' +
-                ", isAuthentication=" + isAuthentication +
-                ", isDeleted=" + isDeleted +
-                ", updateTime=" + updateTime +
-                ", expireTime=" + expireTime +
-                ", createTime=" + createTime +
-                '}';
-    }
+    @Column(name = "EA_CHECK_TIME")
+    private Timestamp checkTime;
 }

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

@@ -37,28 +37,18 @@ public class PersonalAuthPO {
     @Column(name = "PA_ADDRESS")
     private String address;
 
-    @Column(name = "PA_STATUS")
-    private int status;
+    @Column(name = "PA_IS_DELETED")
+    private int isDeleted;
+
+    @Column(name = "PA_IS_AUTHENTICATION")
+    private int isAuthentication;
+
+    @Column(name = "PA_NOT_PASS_EXPLAIN")
+    private String explain;
 
     @Column(name = "PA_APPLY_TIME")
     private Timestamp applyTime;
 
     @Column(name = "PA_CHECK_TIME")
     private Timestamp checkTime;
-
-    @Override
-    public String toString() {
-        return "PersonalAuth{" +
-                "id=" + id +
-                ", userId=" + userId +
-                ", realName='" + realName + '\'' +
-                ", IDCard='" + IDCard + '\'' +
-                ", IDCardPhoto='" + IDCardPhoto + '\'' +
-                ", bankAccount='" + bankAccount + '\'' +
-                ", address='" + address + '\'' +
-                ", status='" + status + '\'' +
-                ", applyTime='" + applyTime + '\'' +
-                ", checkTime='" + checkTime + '\'' +
-                '}';
-    }
 }

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

@@ -58,6 +58,12 @@ public class UserRepo implements IUserRepo {
     @Autowired
     private EvaluationAgencyRepo resourceRepo;
 
+    @Autowired
+    private PersonalAuthDao personalAuthDao;
+
+    @Autowired
+    private CompanyAuthDao companyAuthDao;
+
 
     private Timestamp currentTime = new Timestamp(System.currentTimeMillis());
 
@@ -208,7 +214,7 @@ public class UserRepo implements IUserRepo {
         if (roleList==null || roleList.size()==0){
             UserToRolePO u2r = new UserToRolePO();
             u2r.setUserId(userPO.getId());
-            u2r.setRoleId(1L);
+            u2r.setRoleId(6L);
             userToRoleDao.save(u2r);
         }
         List<UserToRolePO> userToRolePOList = userToRoleDao.findByUserId(userPO.getId());
@@ -223,6 +229,7 @@ public class UserRepo implements IUserRepo {
             }
         }
 
+        /*机构认证保存机构信息*/
         EvaluationAgency evaluationAgency = user.getEvaluationAgency();
         if(evaluationAgency != null){
             EvaluationAgencyPO evaluationAgencyPO = Converter.convert(EvaluationAgencyPO.class, evaluationAgency);
@@ -246,6 +253,17 @@ public class UserRepo implements IUserRepo {
 //                evaluationAgencyResourceDao.save(evaluationAgencyResourcePO);
 //            }
         }
+
+        /*实名认证保存个人信息*/
+        if(user.getPersonalAuth() != null){
+            personalAuthDao.save(Converter.convert(PersonalAuthPO.class, user.getPersonalAuth()));
+        }
+
+        /*企业认证保存企业信息*/
+        if(user.getCompanyAuth() != null){
+            companyAuthDao.save(Converter.convert(CompanyAuthPO.class, user.getCompanyAuth()));
+        }
+
         return getByID(userPO.getId());
     }
 
@@ -339,6 +357,12 @@ public class UserRepo implements IUserRepo {
             userResult.setEvaluationAgency(evaluationAgencyResult);
         }
 
+        /*获取个人认证的信息*/
+        PersonalAuthPO personalAuthPO = personalAuthDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
+        if(personalAuthPO != null){
+            userResult.setPersonalAuth(Converter.convert(PersonalAuth.class, personalAuthPO));
+        }
+
         /*获取区域管理员信息*/
         List<RegionalManagerPO> regionalManagerPOList = regionalManagerDao.findByUserId(userPO.getId());
 //        List<RegionalManager> regionalManagerListResult = new ArrayList<>();

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio