瀏覽代碼

增加个人认证的修改和删除操作

guochao 6 年之前
父節點
當前提交
b1a72fe539

文件差異過大導致無法顯示
+ 0 - 0
core/src/main/java/com/mooctest/crowd/domain/controller/TestUserController.java


+ 18 - 0
core/src/main/java/com/mooctest/crowd/domain/dao/SystemAdministratorToUserDao.java

@@ -0,0 +1,18 @@
+package com.mooctest.crowd.domain.dao;
+
+import com.mooctest.crowd.domain.model.SystemAdministratorToUserPO;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author guochao
+ * @date 2019-08-24 09:42
+ */
+public interface SystemAdministratorToUserDao extends CrudRepository<SystemAdministratorToUserPO, Long> {
+
+    SystemAdministratorToUserPO findByIdAndIsDeleted(Long Long, int isNotDeleted);
+
+    SystemAdministratorToUserPO findByUserIdAndIsDeleted(Long id, int isNotDeleted);
+
+    @Override
+    <S extends SystemAdministratorToUserPO> S save(S s);
+}

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

@@ -1,6 +1,7 @@
 package com.mooctest.crowd.domain.domainobject;
 
 import lombok.Data;
+import org.springframework.beans.BeanUtils;
 
 import java.sql.Timestamp;
 
@@ -46,6 +47,7 @@ public class PersonalAuthentication {
         this.setIsAuthentication(AuthenticationStatus.isAuthenIng);
         this.setIsDeleted(DeletedStatus.isNotDeleted);
         this.setApplyTime(new Timestamp(System.currentTimeMillis()));
+        this.setCheckTime(null);
         this.setExplain("");
         return this;
     }
@@ -63,4 +65,21 @@ public class PersonalAuthentication {
         this.setCheckTime(new Timestamp(System.currentTimeMillis()));
         return this;
     }
+
+    public PersonalAuthentication updateAuthInfo(PersonalAuthentication 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 PersonalAuthentication deleteAuth() {
+        this.isDeleted = DeletedStatus.isDeleted;
+        return this;
+    }
 }

+ 5 - 2
core/src/main/java/com/mooctest/crowd/domain/domainobject/SystemAdministrator.java → core/src/main/java/com/mooctest/crowd/domain/domainobject/SystemAdministratorToUser.java

@@ -2,13 +2,16 @@ package com.mooctest.crowd.domain.domainobject;
 
 import lombok.Data;
 
+import java.sql.Timestamp;
+
 /**
  * @author guochao
  * @date 2019/7/16 16:11
  */
 @Data
-public class SystemAdministrator extends User {
+    public class SystemAdministratorToUser {
     private Long id;
     private Long userId;
-
+    private int isDeleted;
+    private Timestamp createTime;
 }

+ 45 - 10
core/src/main/java/com/mooctest/crowd/domain/domainobject/User.java

@@ -1,6 +1,7 @@
 package com.mooctest.crowd.domain.domainobject;
 
 import com.mooctest.crowd.domain.exception.BaseException;
+import com.mooctest.crowd.domain.exception.SystemAdministratorException;
 import lombok.Data;
 
 import java.sql.Timestamp;
@@ -30,6 +31,7 @@ public class User {
     private EvaluationAgency evaluationAgency;
     private PersonalAuthentication personalAuthentication;
     private EnterpriseAuthentication enterpriseAuthentication;
+    private SystemAdministratorToUser systemAdministratorToUser;
     private List<Role> roleList;
 
     @Override
@@ -50,8 +52,9 @@ public class User {
                 ", createTime=" + createTime +
                 ", regionalManager=" + regionalManager +
                 ", evaluationAgency=" + evaluationAgency +
-                ", personalAuth=" + personalAuthentication +
-                ", companyAuth=" + enterpriseAuthentication +
+                ", personalAuthentication=" + personalAuthentication +
+                ", enterpriseAuthentication=" + enterpriseAuthentication +
+                ", systemAdministratorToUser=" + systemAdministratorToUser +
                 ", roleList=" + roleList +
                 '}';
     }
@@ -89,15 +92,20 @@ public class User {
      * 同意通过个人认证
      * @return
      */
-    public User passPersonalAuthApplication() {
-        PersonalAuthentication personalAuth = this.getPersonalAuthentication();
+    public User passPersonalAuthApplication(User personalUser) {
+        //判断是否为系统管理员
+        if(this.getSystemAdministratorToUser() == null){
+            throw new SystemAdministratorException("当前用户不是系统管理员,没有权限进行认证审核操作");
+        }
+
+        PersonalAuthentication personalAuth = personalUser.getPersonalAuthentication();
         if(personalAuth.getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
             throw new BaseException("当前是未通过认证状态,不可通过认证,需对认证信息进行修改后再提交认证申请");
         }else if(personalAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
             throw new BaseException("当前已通过认证,不可再次进行认证");
         }else{
-            this.setPersonalAuthentication(personalAuth.passAuthentication());
-            return this;
+            personalAuth.passAuthentication();
+            return personalUser;
 //            List<Role> roleList = this.getRoleList();
 //            Role role = new Role();
 //            role.setId(1L);
@@ -106,8 +114,18 @@ public class User {
         }
     }
 
-    public User personalAuthFailure(String explain) {
-        PersonalAuthentication personalAuth = this.getPersonalAuthentication();
+    /**
+     * 驳回个人认证,并说明驳回原因
+     * @param explain
+     * @return
+     */
+    public User personalAuthFailure(User personalUser, String explain) {
+        //判断是否为系统管理员
+        if(this.getSystemAdministratorToUser() == null){
+            throw new SystemAdministratorException("当前用户不是系统管理员,没有权限进行认证审核操作");
+        }
+
+        PersonalAuthentication personalAuth = personalUser.getPersonalAuthentication();
         if(personalAuth.getIsDeleted() == DeletedStatus.isDeleted){
             throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
         }else {
@@ -116,9 +134,26 @@ public class User {
             }else if(personalAuth.getIsAuthentication() == AuthenticationStatus.isAuthenticated){
                 throw new BaseException("当前已通过认证,不可拒绝认证");
             }else {
-                this.setPersonalAuthentication(personalAuth.rejectAuthentication(explain));
-                return this;
+                personalAuth.rejectAuthentication(explain);
+                return personalUser;
             }
         }
     }
+
+    /**
+     * 修改个人认证信息
+     * @param modifyAuth
+     * @return
+     */
+    public User updatePersonalAuthInfo(PersonalAuthentication modifyAuth){
+        if (this.getEvaluationAgency()!=null || this.getEnterpriseAuthentication()!=null)
+            throw new BaseException("已有其他认证信息,不可对个人认证进行操作");
+        this.getPersonalAuthentication().updateAuthInfo(modifyAuth);
+        return this;
+    }
+
+    public User deletePersonalAuthInfo() {
+        this.getPersonalAuthentication().deleteAuth();
+        return this;
+    }
 }

+ 12 - 0
core/src/main/java/com/mooctest/crowd/domain/exception/SystemAdministratorException.java

@@ -0,0 +1,12 @@
+package com.mooctest.crowd.domain.exception;
+
+/**
+ * @author guochao
+ * @date 2019-08-24 09:56
+ */
+public class SystemAdministratorException extends BaseException {
+
+    public SystemAdministratorException(String msg){
+        super(msg);
+    }
+}

+ 29 - 0
core/src/main/java/com/mooctest/crowd/domain/model/SystemAdministratorToUserPO.java

@@ -0,0 +1,29 @@
+package com.mooctest.crowd.domain.model;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * @author guochao
+ * @date 2019-08-24 09:37
+ */
+@Data
+@Entity
+@Table(name="system_administrator_to_user")
+public class SystemAdministratorToUserPO {
+    @Id
+    @Column(name = "SATU_ID")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    @Column(name = "SATU_U_ID")
+    private Long userId;
+
+    @Column(name = "SATU_IS_DELETED")
+    private int isDeleted;
+
+    @Column(name = "SATU_CREATE_TIME")
+    private Timestamp createTime;
+}

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

@@ -64,6 +64,8 @@ public class UserRepo implements IUserRepo {
     @Autowired
     private EnterpriseAuthenticationDao enterpriseAuthenticationDao;
 
+    @Autowired
+    private SystemAdministratorToUserDao systemAdministratorToUserDao;
 
     private Timestamp currentTime = new Timestamp(System.currentTimeMillis());
 
@@ -385,6 +387,13 @@ public class UserRepo implements IUserRepo {
             regionalManager.setRegionalList(regionalList);
             userResult.setRegionalManager(regionalManager);
         }
+
+        //获取系统管理员信息
+        SystemAdministratorToUserPO systemAdministratorToUserPO = systemAdministratorToUserDao.findByUserIdAndIsDeleted(userPO.getId(), DeletedStatus.isNotDeleted);
+        if(systemAdministratorToUserPO != null){
+            userResult.setSystemAdministratorToUser(Converter.convert(SystemAdministratorToUser.class, systemAdministratorToUserPO));
+        }
+
         return userResult;
     }
 

部分文件因文件數量過多而無法顯示