Sfoglia il codice sorgente

修改机构认证申请、修改、删除操作

guochao 6 anni fa
parent
commit
ee046d3cbc

+ 0 - 16
core/src/main/java/com/mooctest/crowd/domain/configuration/DefaultFeatureConfiguration.java

@@ -1,16 +0,0 @@
-package com.mooctest.crowd.domain.configuration;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * Created by lipeiyuan on 2018/3/12.
- */
-@Data
-@Component
-@ConfigurationProperties(prefix = "feature-switch.default")
-public class DefaultFeatureConfiguration {
-
-    private String role;
-}

+ 19 - 0
core/src/main/java/com/mooctest/crowd/domain/configuration/RoleConfiguration.java

@@ -0,0 +1,19 @@
+package com.mooctest.crowd.domain.configuration;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by guochao on 2019/8/12.
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "role-list")
+public class RoleConfiguration {
+    private Long generalUser;
+    private Long evaluationAgency;
+    private Long regionalManager;
+    private Long systemAdministrator;
+    private Long enterpriseUser;
+}

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


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

@@ -13,7 +13,7 @@ public interface AgencyAbilityDao extends PagingAndSortingRepository<EvaluationA
 
     Optional<EvaluationAgencyAbilityPO> findById(Long Id);
 
-    List<EvaluationAgencyAbilityPO> findByEvaluationAgencyId(Long evaluationAgencyId);
+    List<EvaluationAgencyAbilityPO> findByEvaluationAgencyIdAndIsDeleted(Long evaluationAgencyId, int isNotDeleted);
 
     List<EvaluationAgencyAbilityPO> findAll();
 

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

@@ -13,7 +13,7 @@ public interface AgencyResourceDao extends PagingAndSortingRepository<Evaluation
 
     Optional<EvaluationAgencyResourcePO> findById(Long Id);
 
-    List<EvaluationAgencyResourcePO> findByEvaluationAgencyId(Long evaluationAgencyId);
+    List<EvaluationAgencyResourcePO> findByEvaluationAgencyIdAndIsDeleted(Long evaluationAgencyId, int isNotDeleted);
 
 //    List<EvaluationAgencyResourcePO> findByCountGreaterThanEqual(int professionalsFreeCount);
 

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

@@ -87,6 +87,9 @@ public class EvaluationAgency {
 
     public EvaluationAgency deleteAuth() {
         this.isDeleted = DeletedStatus.isDeleted;
+        //删除资源和能力
+        this.getEvaluationAgencyResourceList().stream().forEach(evaluationAgencyResource -> evaluationAgencyResource.deleteResource());
+        this.getEvaluationAgencyAbilityList().stream().forEach(evaluationAgencyAbility -> evaluationAgencyAbility.deleteAbility());
         return this;
     }
 }

+ 11 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/EvaluationAgencyAbility.java

@@ -3,6 +3,8 @@ package com.mooctest.crowd.domain.domainobject;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.sql.Timestamp;
+
 /**
  * @author guochao
  * @date 2019/8/12 14:16
@@ -14,6 +16,8 @@ public class EvaluationAgencyAbility {
     private Long id;
     private Long evaluationAgencyId;
     private String abilityName;
+    private int isDeleted;
+    private Timestamp createTime;
 
     public EvaluationAgencyAbility(String abilityName){
         this.abilityName = abilityName;
@@ -25,6 +29,13 @@ public class EvaluationAgencyAbility {
                 "id=" + id +
                 ", evaluationAgencyId=" + evaluationAgencyId +
                 ", abilityName='" + abilityName + '\'' +
+                ", isDeleted=" + isDeleted +
+                ", createTime=" + createTime +
                 '}';
     }
+
+    public EvaluationAgencyAbility deleteAbility(){
+        this.isDeleted = DeletedStatus.isDeleted;
+        return this;
+    }
 }

+ 11 - 0
core/src/main/java/com/mooctest/crowd/domain/domainobject/EvaluationAgencyResource.java

@@ -2,6 +2,8 @@ package com.mooctest.crowd.domain.domainobject;
 
 import lombok.Data;
 
+import java.sql.Timestamp;
+
 /**
  * @author guochao
  * @date 2019/8/12 14:16
@@ -15,6 +17,8 @@ public class EvaluationAgencyResource {
     private String name;
     private int totalNum;
     private int availableNum;
+    private int isDeleted;
+    private Timestamp createTime;
 
     @Override
     public String toString() {
@@ -25,6 +29,8 @@ public class EvaluationAgencyResource {
                 ", name='" + name + '\'' +
                 ", totalNum=" + totalNum +
                 ", availableNum=" + availableNum +
+                ", isDeleted=" + isDeleted +
+                ", createTime=" + createTime +
                 '}';
     }
 
@@ -35,4 +41,9 @@ public class EvaluationAgencyResource {
         this.availableNum = Integer.valueOf(resource[3]);
         return this;
     }
+
+    public EvaluationAgencyResource deleteResource(){
+        this.isDeleted = DeletedStatus.isDeleted;
+        return this;
+    }
 }

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

@@ -65,9 +65,12 @@ public class User {
      * @return
      */
     public User applyAgencyAuthentication(EvaluationAgency evaluationAgency) {
-        if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
+        if (this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
             throw new BaseException("已有认证信息,不可再次认证");
-        this.setEvaluationAgency(evaluationAgency.applyAuthentication(this.id));
+        if (this.getEvaluationAgency()!=null && this.getEvaluationAgency().getIsAuthentication() != AuthenticationStatus.isAuthenticated){
+            evaluationAgency.setId(this.getEvaluationAgency().getId());
+            this.setEvaluationAgency(evaluationAgency.applyAuthentication(this.id));
+        }
         return this;
     }
 
@@ -118,6 +121,7 @@ public class User {
                 return agencyUser;
             }
         }
+
     }
 
     /**
@@ -128,7 +132,9 @@ public class User {
     public User updateAgencyAuthInfo(EvaluationAgency modifyAuth){
         if (this.getEnterpriseAuthentication()!=null || this.getPersonalAuthentication()!=null)
             throw new BaseException("已有其他认证信息,不可对认证未企业用户");
-
+        if (this.getEvaluationAgency().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("已通过认证,不可修改认证信息");
+        }
         this.getEvaluationAgency().updateAuthInfo(modifyAuth);
         return this;
     }
@@ -138,7 +144,10 @@ public class User {
      * @return
      */
     public User deleteAgencyAuthInfo() {
-        this.getEvaluationAgency().deleteAuth();
+        EvaluationAgency evaluationAgency = this.getEvaluationAgency();
+//        RoleConfiguration roleConfiguration = new RoleConfiguration();
+//        final Long num = roleConfiguration.getGeneralUser();
+        evaluationAgency.deleteAuth();
         return this;
     }
 
@@ -148,9 +157,12 @@ public class User {
      * @return
      */
     public User applyPersonalAuthentication(PersonalAuthentication personalAuth) {
-        if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
+        if (this.getEvaluationAgency()!=null || this.getEnterpriseAuthentication()!=null)
             throw new BaseException("已有认证信息,不可再次认证");
-        this.setPersonalAuthentication(personalAuth.applyAuthentication(this.id));
+        if (this.getPersonalAuthentication()!=null && this.getPersonalAuthentication().getIsAuthentication() != AuthenticationStatus.isAuthenticated){
+            personalAuth.setId(this.getPersonalAuthentication().getId());
+            this.setPersonalAuthentication(personalAuth.applyAuthentication(this.id));
+        }
         return this;
     }
 
@@ -170,11 +182,6 @@ public class User {
         }else{
             personalAuth.passAuthentication();
             return personalUser;
-//            List<Role> roleList = this.getRoleList();
-//            Role role = new Role();
-//            role.setId(1L);
-//            roleList.add(role);
-//            this.setRoleList(roleList);
         }
     }
 
@@ -210,7 +217,9 @@ public class User {
     public User updatePersonalAuthInfo(PersonalAuthentication modifyAuth){
         if (this.getEvaluationAgency()!=null || this.getEnterpriseAuthentication()!=null)
             throw new BaseException("已有其他认证信息,不可对个人认证进行操作");
-
+        if (this.getPersonalAuthentication().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("已通过认证,不可修改认证信息");
+        }
         this.getPersonalAuthentication().updateAuthInfo(modifyAuth);
         return this;
     }
@@ -231,7 +240,10 @@ public class User {
     public User applyEnterpriseAuthentication(EnterpriseAuthentication enterpriseAuth) {
         if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null || this.getEnterpriseAuthentication()!=null)
             throw new BaseException("已有认证信息,不可再次认证");
-        this.setEnterpriseAuthentication(enterpriseAuth.applyAuthentication(this.id));
+        if (this.getEnterpriseAuthentication()!=null && this.getEnterpriseAuthentication().getIsAuthentication() != AuthenticationStatus.isAuthenticated){
+            enterpriseAuth.setId(this.getEnterpriseAuthentication().getId());
+            this.setEnterpriseAuthentication(enterpriseAuth.applyAuthentication(this.id));
+        }
         return this;
     }
 
@@ -291,7 +303,9 @@ public class User {
     public User updateEnterpriseAuthInfo(EnterpriseAuthentication modifyAuth){
         if (this.getEvaluationAgency()!=null || this.getPersonalAuthentication()!=null)
             throw new BaseException("已有其他认证信息,不可对认证未企业用户");
-
+        if (this.getEnterpriseAuthentication().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
+            throw new BaseException("已通过认证,不可修改认证信息");
+        }
         this.getEnterpriseAuthentication().updateAuthInfo(modifyAuth);
         return this;
     }

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

@@ -3,6 +3,7 @@ package com.mooctest.crowd.domain.model;
 import lombok.Data;
 
 import javax.persistence.*;
+import java.sql.Timestamp;
 
 /**
  * @author guochao
@@ -23,12 +24,9 @@ public class EvaluationAgencyAbilityPO {
     @Column(name = "EAA_ABILITY_NAME")
     private String abilityName;
 
-    @Override
-    public String toString() {
-        return "EvaluationAgencyAbility{" +
-                "id=" + id +
-                ", evaluationAgencyId=" + evaluationAgencyId +
-                ", abilityName='" + abilityName + '\'' +
-                '}';
-    }
+    @Column(name = "EAA_IS_DELETED")
+    private int isDeleted;
+
+    @Column(name = "EAA_CREATE_TIME")
+    private Timestamp createTime;
 }

+ 6 - 11
core/src/main/java/com/mooctest/crowd/domain/model/EvaluationAgencyResourcePO.java

@@ -3,6 +3,7 @@ package com.mooctest.crowd.domain.model;
 import lombok.Data;
 
 import javax.persistence.*;
+import java.sql.Timestamp;
 
 /**
  * @author guochao
@@ -32,15 +33,9 @@ public class EvaluationAgencyResourcePO {
     @Column(name = "EAR_AVAILABLE_NUM")
     private int availableNum;
 
-    @Override
-    public String toString() {
-        return "EvaluationAgencyResourcePO{" +
-                "id=" + id +
-                ", evaluationAgencyId=" + evaluationAgencyId +
-                ", type='" + type + '\'' +
-                ", name='" + name + '\'' +
-                ", totalNum=" + totalNum +
-                ", availableNum=" + availableNum +
-                '}';
-    }
+    @Column(name = "EAR_IS_DELETED")
+    private int isDeleted;
+
+    @Column(name = "EAR_CREATE_TIME")
+    private Timestamp createTime;
 }

+ 2 - 1
core/src/main/java/com/mooctest/crowd/domain/repository/EvaluationAgencyRepo.java

@@ -2,6 +2,7 @@ package com.mooctest.crowd.domain.repository;
 
 import com.mooctest.crowd.domain.dao.AgencyAbilityDao;
 import com.mooctest.crowd.domain.dao.AgencyResourceDao;
+import com.mooctest.crowd.domain.domainobject.DeletedStatus;
 import com.mooctest.crowd.domain.domainobject.EvaluationAgencyAbility;
 import com.mooctest.crowd.domain.domainobject.EvaluationAgencyResource;
 import com.mooctest.crowd.domain.exception.EvaluationAgencyResourceNotExist;
@@ -39,7 +40,7 @@ public class EvaluationAgencyRepo implements IEvaluationAgencyRepo {
 
     @Override
     public List<EvaluationAgencyResource> findByEvaluationAgencyId(Long evaluationAgencyId){
-        List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyId(evaluationAgencyId);
+        List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyId, DeletedStatus.isNotDeleted);
         return evaluationAgencyResourcePOList.stream().map(evaluationAgencyResourcePO -> Converter.convert(EvaluationAgencyResource.class, evaluationAgencyResourcePO)).collect(Collectors.toList());
 
     }

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

@@ -335,7 +335,7 @@ public class UserRepo implements IUserRepo {
             EvaluationAgency evaluationAgencyResult = Converter.convert(EvaluationAgency.class, evaluationAgencyPO);
 
             /*获取测评机构能力*/
-            List<EvaluationAgencyAbilityPO> evaluationAgencyAbilityPOList = agencyAbilityDao.findByEvaluationAgencyId(evaluationAgencyResult.getId());
+            List<EvaluationAgencyAbilityPO> evaluationAgencyAbilityPOList = agencyAbilityDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
             List<EvaluationAgencyAbility> evaluationAgencyAbilityList = new ArrayList<>();
             if(evaluationAgencyAbilityPOList.size() != 0){
                 for(EvaluationAgencyAbilityPO evaluationAgencyAbilityPO : evaluationAgencyAbilityPOList){
@@ -346,7 +346,7 @@ public class UserRepo implements IUserRepo {
             }
 
             /*获取测评机构资源*/
-            List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyId(evaluationAgencyResult.getId());
+            List<EvaluationAgencyResourcePO> evaluationAgencyResourcePOList = agencyResourceDao.findByEvaluationAgencyIdAndIsDeleted(evaluationAgencyResult.getId(), DeletedStatus.isNotDeleted);
             List<EvaluationAgencyResource> evaluationAgencyResourceList = new ArrayList<>();
             if(evaluationAgencyResourcePOList.size() != 0){
                 for(EvaluationAgencyResourcePO evaluationAgencyResourcePO : evaluationAgencyResourcePOList){

+ 7 - 3
core/src/main/resources/application.yml

@@ -30,9 +30,13 @@ spring:
   # The SQL dialect makes Hibernate generate better SQL for the chosen database
   properties.hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
 
-feature-switch:
-  default:
-    role: generalUser
+role-list:
+  general-user: 1
+  evaluation-agency: 2
+  regional-manager: 3
+  system-administrator: 4
+  enterprise-user: 5
+
 
 #swagger:
 #  enable: true

+ 3 - 3
core/src/test/java/com/mooctest/crowd/domain/repository/UserRepoTest.java

@@ -154,8 +154,8 @@ public class UserRepoTest {
         when(roleToPermissionDao.findAllByRoleId(anyLong())).thenReturn(expectRoleToPermissionPOList);
         when(permissionDao.findById(anyLong())).thenReturn(Optional.of(expectPermission));
         when(evaluationAgencyDao.findByUserId(anyLong())).thenReturn(expectEvaluationAgencyPO);
-        when(agencyAbilityDao.findByEvaluationAgencyId(anyLong())).thenReturn(evaluationAgencyAbilityPOList);
-        when(agencyResourceDao.findByEvaluationAgencyId(anyLong())).thenReturn(evaluationAgencyResourcePOList);
+        when(agencyAbilityDao.findByEvaluationAgencyIdAndIsDeleted(anyLong(), anyInt())).thenReturn(evaluationAgencyAbilityPOList);
+        when(agencyResourceDao.findByEvaluationAgencyIdAndIsDeleted(anyLong(), anyInt())).thenReturn(evaluationAgencyResourcePOList);
         when(regionalManagerDao.findByUserId(anyLong())).thenReturn(expectRegionalPOManagerList);
         when(regionalDao.findById(anyLong())).thenReturn(Optional.of(expectRegionalPO));
         //action
@@ -181,7 +181,7 @@ public class UserRepoTest {
         when(roleToPermissionDao.findAllByRoleId(anyLong())).thenReturn(expectRoleToPermissionPOList);
         when(permissionDao.findById(anyLong())).thenReturn(Optional.of(expectPermission));
         when(evaluationAgencyDao.findByUserId(anyLong())).thenReturn(expectEvaluationAgencyPO);
-        when(agencyAbilityDao.findByEvaluationAgencyId(anyLong())).thenReturn(evaluationAgencyAbilityPOList);
+        when(agencyAbilityDao.findByEvaluationAgencyIdAndIsDeleted(anyLong(), anyInt())).thenReturn(evaluationAgencyAbilityPOList);
         when(regionalManagerDao.findByUserId(anyLong())).thenReturn(expectRegionalPOManagerList);
         when(regionalDao.findById(anyLong())).thenReturn(Optional.of(expectRegionalPO));
         when(roleDao.findById(anyLong())).thenReturn(Optional.empty());

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