From acbdf63875e7f43b9f0e29e93170bb3580863398 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 17 Feb 2020 17:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E9=87=8F=E4=BF=AE=E6=94=B9=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=A4=A7=E9=87=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 13 ++++ .../ase/component/ASESpringUtil.java | 21 +++++++ .../DataModelRepositorySearcher.java | 46 ++++++++++++++ .../datamanager/DataModelSearcher.java | 62 +++++++++++++++++++ .../{ => permission}/ASEPasswordEncoder.java | 2 +- .../ASESecurityAuthenticationProvider.java | 4 +- .../{ => permission}/ASEUsernameEncoder.java | 2 +- .../UserAuthoritiesGenerator.java | 2 +- ...onalPermissionContainersListGenerator.java | 12 +--- ...FunctionalScopeRelationsListGenerator.java | 11 +--- ...ionContainersCollectionsListGenerator.java | 11 +--- .../UserRolesListGenerator.java | 13 ++-- .../UserTagsListGenerator.java | 4 +- .../{ => permission}/UsersListGenerator.java | 2 +- .../configure/CustomWebSecurityConfig.java | 5 +- .../ase/controller/DataManagerController.java | 40 ++++++++++++ .../information/BaseCandidateCategory.java | 20 ++++++ .../ase/model/information/BaseCollege.java | 3 + .../information/BasePoliticalStatus.java | 19 ++++++ .../model/information/BaseStudentInfo.java | 42 +++++++++++++ .../codesdream/ase/model/permission/User.java | 5 -- .../BaseStudentInfoRepository.java | 14 +++++ .../FunctionalPermissionRepository.java | 2 +- ...missionContainersCollectionRepository.java | 2 +- .../ScopePermissionRepository.java | 2 +- .../{ => permission}/TagRepository.java | 2 +- .../{ => permission}/UserRepository.java | 2 +- .../ase/service/ASEUserDetailsService.java | 3 +- .../ase/service/PermissionService.java | 12 ++-- .../codesdream/ase/service/UserService.java | 8 +-- .../codesdream/ase/test/DataManagerTest.java | 37 +++++++++++ .../com/codesdream/ase/test/UserTest.java | 3 +- 32 files changed, 356 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/codesdream/ase/component/ASESpringUtil.java create mode 100644 src/main/java/com/codesdream/ase/component/datamanager/DataModelRepositorySearcher.java create mode 100644 src/main/java/com/codesdream/ase/component/datamanager/DataModelSearcher.java rename src/main/java/com/codesdream/ase/component/{ => permission}/ASEPasswordEncoder.java (91%) rename src/main/java/com/codesdream/ase/component/{ => permission}/ASESecurityAuthenticationProvider.java (94%) rename src/main/java/com/codesdream/ase/component/{ => permission}/ASEUsernameEncoder.java (89%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UserAuthoritiesGenerator.java (90%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UserFunctionalPermissionContainersListGenerator.java (78%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UserFunctionalScopeRelationsListGenerator.java (78%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UserPermissionContainersCollectionsListGenerator.java (82%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UserRolesListGenerator.java (82%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UserTagsListGenerator.java (93%) rename src/main/java/com/codesdream/ase/component/{ => permission}/UsersListGenerator.java (91%) create mode 100644 src/main/java/com/codesdream/ase/controller/DataManagerController.java create mode 100644 src/main/java/com/codesdream/ase/model/information/BaseCandidateCategory.java create mode 100644 src/main/java/com/codesdream/ase/model/information/BasePoliticalStatus.java create mode 100644 src/main/java/com/codesdream/ase/model/information/BaseStudentInfo.java create mode 100644 src/main/java/com/codesdream/ase/repository/information/BaseStudentInfoRepository.java rename src/main/java/com/codesdream/ase/repository/{ => permission}/FunctionalPermissionRepository.java (89%) rename src/main/java/com/codesdream/ase/repository/{ => permission}/PermissionContainersCollectionRepository.java (89%) rename src/main/java/com/codesdream/ase/repository/{ => permission}/ScopePermissionRepository.java (86%) rename src/main/java/com/codesdream/ase/repository/{ => permission}/TagRepository.java (89%) rename src/main/java/com/codesdream/ase/repository/{ => permission}/UserRepository.java (88%) create mode 100644 src/main/java/com/codesdream/ase/test/DataManagerTest.java diff --git a/pom.xml b/pom.xml index 024f723..cecdf60 100644 --- a/pom.xml +++ b/pom.xml @@ -113,6 +113,19 @@ 1.16.10 + + org.apache.poi + poi + 3.14 + + + + + org.apache.poi + poi-ooxml + 3.14 + + diff --git a/src/main/java/com/codesdream/ase/component/ASESpringUtil.java b/src/main/java/com/codesdream/ase/component/ASESpringUtil.java new file mode 100644 index 0000000..d60f1bf --- /dev/null +++ b/src/main/java/com/codesdream/ase/component/ASESpringUtil.java @@ -0,0 +1,21 @@ +package com.codesdream.ase.component; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 手动获得Bean的工具类 + */ +@Component +public class ASESpringUtil { + @Resource + private ApplicationContext applicationContext; + + public T getBean(Class tClass){ + return applicationContext.getBean(tClass); + } +} diff --git a/src/main/java/com/codesdream/ase/component/datamanager/DataModelRepositorySearcher.java b/src/main/java/com/codesdream/ase/component/datamanager/DataModelRepositorySearcher.java new file mode 100644 index 0000000..d3061b7 --- /dev/null +++ b/src/main/java/com/codesdream/ase/component/datamanager/DataModelRepositorySearcher.java @@ -0,0 +1,46 @@ +package com.codesdream.ase.component.datamanager; + +import com.codesdream.ase.component.ASESpringUtil; +import lombok.Data; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * DataModel对应Repository层查询器 + */ +@Data +@Component +@Scope("prototype") +public class DataModelRepositorySearcher { + @Resource + ASESpringUtil springUtil; + + public final String repositoryPath = "com.codesdream.ase.repository."; + + private Class repositoryClass = null; + + private boolean present; + + public void getDataModelRepositoryClass(String subSystem, String dataModel){ + try { + this.repositoryClass = Class.forName(dataModelFullNameGenerator(subSystem, dataModel)); + this.setPresent(true); + } catch (ClassNotFoundException e) { + this.setPresent(false); + } + } + + public T getDataModelRepositoryInstance(Class dataModeRepositoryClass) { + if(isPresent()) { + return springUtil.getBean(dataModeRepositoryClass); + } + return null; + } + + private String dataModelFullNameGenerator(String subSystem, String dataModel){ + return new String(repositoryPath + subSystem + "." + dataModel + "Repository"); + } + +} diff --git a/src/main/java/com/codesdream/ase/component/datamanager/DataModelSearcher.java b/src/main/java/com/codesdream/ase/component/datamanager/DataModelSearcher.java new file mode 100644 index 0000000..abb898c --- /dev/null +++ b/src/main/java/com/codesdream/ase/component/datamanager/DataModelSearcher.java @@ -0,0 +1,62 @@ +package com.codesdream.ase.component.datamanager; + +import lombok.Data; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import javax.swing.text.html.parser.Entity; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collection; + +/** + * 查找特定的Model以创建相应的操作表单(多例模式) + */ +@Data +@Component +@Scope("prototype") +public class DataModelSearcher { + public final String modelPath = "com.codesdream.ase.model."; + private Class dataModelClass = null; + + private boolean present; + + public void getDataModelClass(String subSystem, String dataModel) { + try { + dataModelClass = Class.forName(dataModelFullNameGenerator(subSystem, dataModel)); + this.setPresent(true); + }catch (ClassNotFoundException e){ + this.setPresent(false); + } + } + + public Collection getDataModelParamArgs() { + if(isPresent()) { + Collection paramArgs = new ArrayList<>(); + for (Field field : dataModelClass.getDeclaredFields()) { + paramArgs.add(field.getName()); + } + return paramArgs; + } + return null; + } + + public T getDataModelInstance(Class dataModelClass) { + if(isPresent()){ + try { + return dataModelClass.newInstance(); + } catch (IllegalAccessException e) { + this.setPresent(false); + return null; + } catch (InstantiationException e) { + e.printStackTrace(); + return null; + } + } + return null; + } + + private String dataModelFullNameGenerator(String subSystem, String dataModel){ + return new String(modelPath + subSystem + "." + dataModel); + } +} diff --git a/src/main/java/com/codesdream/ase/component/ASEPasswordEncoder.java b/src/main/java/com/codesdream/ase/component/permission/ASEPasswordEncoder.java similarity index 91% rename from src/main/java/com/codesdream/ase/component/ASEPasswordEncoder.java rename to src/main/java/com/codesdream/ase/component/permission/ASEPasswordEncoder.java index 62e284f..2682436 100644 --- a/src/main/java/com/codesdream/ase/component/ASEPasswordEncoder.java +++ b/src/main/java/com/codesdream/ase/component/permission/ASEPasswordEncoder.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.security.crypto.password.PasswordEncoder; diff --git a/src/main/java/com/codesdream/ase/component/ASESecurityAuthenticationProvider.java b/src/main/java/com/codesdream/ase/component/permission/ASESecurityAuthenticationProvider.java similarity index 94% rename from src/main/java/com/codesdream/ase/component/ASESecurityAuthenticationProvider.java rename to src/main/java/com/codesdream/ase/component/permission/ASESecurityAuthenticationProvider.java index e2cf120..7092134 100644 --- a/src/main/java/com/codesdream/ase/component/ASESecurityAuthenticationProvider.java +++ b/src/main/java/com/codesdream/ase/component/permission/ASESecurityAuthenticationProvider.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import org.springframework.security.authentication.*; import org.springframework.security.core.Authentication; @@ -11,8 +11,6 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.io.UnsupportedEncodingException; -import java.security.NoSuchAlgorithmException; import java.util.Collection; @Component diff --git a/src/main/java/com/codesdream/ase/component/ASEUsernameEncoder.java b/src/main/java/com/codesdream/ase/component/permission/ASEUsernameEncoder.java similarity index 89% rename from src/main/java/com/codesdream/ase/component/ASEUsernameEncoder.java rename to src/main/java/com/codesdream/ase/component/permission/ASEUsernameEncoder.java index 834dcf5..eee9acf 100644 --- a/src/main/java/com/codesdream/ase/component/ASEUsernameEncoder.java +++ b/src/main/java/com/codesdream/ase/component/permission/ASEUsernameEncoder.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/codesdream/ase/component/UserAuthoritiesGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UserAuthoritiesGenerator.java similarity index 90% rename from src/main/java/com/codesdream/ase/component/UserAuthoritiesGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UserAuthoritiesGenerator.java index 52abd66..3963c38 100644 --- a/src/main/java/com/codesdream/ase/component/UserAuthoritiesGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UserAuthoritiesGenerator.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import com.codesdream.ase.model.permission.User; import org.springframework.security.core.GrantedAuthority; diff --git a/src/main/java/com/codesdream/ase/component/UserFunctionalPermissionContainersListGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UserFunctionalPermissionContainersListGenerator.java similarity index 78% rename from src/main/java/com/codesdream/ase/component/UserFunctionalPermissionContainersListGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UserFunctionalPermissionContainersListGenerator.java index 535af65..97de9f3 100644 --- a/src/main/java/com/codesdream/ase/component/UserFunctionalPermissionContainersListGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UserFunctionalPermissionContainersListGenerator.java @@ -1,8 +1,9 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import com.codesdream.ase.model.permission.*; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Collection; @@ -11,16 +12,9 @@ import java.util.Collection; */ @Component public class UserFunctionalPermissionContainersListGenerator { - + @Resource private UserFunctionalScopeRelationsListGenerator functionalScopeRelationsListGenerator; - public UserFunctionalPermissionContainersListGenerator( - UserFunctionalScopeRelationsListGenerator userFunctionalScopeRelationsListGenerator) - { - if(userFunctionalScopeRelationsListGenerator == null) throw new NullPointerException(); - this.functionalScopeRelationsListGenerator = userFunctionalScopeRelationsListGenerator; - } - public Collection generateFunctionalContainers( Collection functionalScopeRelations){ Collection functionalPermissionContainers diff --git a/src/main/java/com/codesdream/ase/component/UserFunctionalScopeRelationsListGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UserFunctionalScopeRelationsListGenerator.java similarity index 78% rename from src/main/java/com/codesdream/ase/component/UserFunctionalScopeRelationsListGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UserFunctionalScopeRelationsListGenerator.java index 2b213a0..5bed3b3 100644 --- a/src/main/java/com/codesdream/ase/component/UserFunctionalScopeRelationsListGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UserFunctionalScopeRelationsListGenerator.java @@ -1,10 +1,11 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import com.codesdream.ase.model.permission.FunctionalScopeRelation; import com.codesdream.ase.model.permission.PermissionContainersCollection; import com.codesdream.ase.model.permission.User; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Collection; @@ -14,15 +15,9 @@ import java.util.Collection; @Component public class UserFunctionalScopeRelationsListGenerator { + @Resource private UserPermissionContainersCollectionsListGenerator userPermissionContainersCollectionsListGenerator; - public UserFunctionalScopeRelationsListGenerator( - UserPermissionContainersCollectionsListGenerator userPermissionContainersCollectionsListGenerator) - { - if(userPermissionContainersCollectionsListGenerator == null) throw new NullPointerException(); - this.userPermissionContainersCollectionsListGenerator = - userPermissionContainersCollectionsListGenerator; - } public Collection generateFunctionalScopeRelations( Collection permissionContainersCollections){ diff --git a/src/main/java/com/codesdream/ase/component/UserPermissionContainersCollectionsListGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UserPermissionContainersCollectionsListGenerator.java similarity index 82% rename from src/main/java/com/codesdream/ase/component/UserPermissionContainersCollectionsListGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UserPermissionContainersCollectionsListGenerator.java index 88f161e..0a1fc50 100644 --- a/src/main/java/com/codesdream/ase/component/UserPermissionContainersCollectionsListGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UserPermissionContainersCollectionsListGenerator.java @@ -1,10 +1,11 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import com.codesdream.ase.model.permission.PermissionContainersCollection; import com.codesdream.ase.model.permission.Tag; import com.codesdream.ase.model.permission.User; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Collection; @@ -13,15 +14,9 @@ import java.util.Collection; */ @Component public class UserPermissionContainersCollectionsListGenerator { - + @Resource private UserTagsListGenerator userTagsListGenerator; - public UserPermissionContainersCollectionsListGenerator(UserTagsListGenerator userTagsListGenerator) - { - if(userTagsListGenerator == null) throw new NullPointerException(); - this.userTagsListGenerator = userTagsListGenerator; - } - public Collection generatePermissionContainerCollections( Collection tags){ Collection permissionContainersCollections = diff --git a/src/main/java/com/codesdream/ase/component/UserRolesListGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UserRolesListGenerator.java similarity index 82% rename from src/main/java/com/codesdream/ase/component/UserRolesListGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UserRolesListGenerator.java index c4317c7..1e39c9e 100644 --- a/src/main/java/com/codesdream/ase/component/UserRolesListGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UserRolesListGenerator.java @@ -1,11 +1,13 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; +import com.codesdream.ase.component.permission.UserFunctionalPermissionContainersListGenerator; import com.codesdream.ase.model.permission.FunctionalPermissionContainer; import com.codesdream.ase.model.permission.User; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.ArrayList; import java.util.Collection; @@ -14,16 +16,9 @@ import java.util.Collection; */ @Component public class UserRolesListGenerator { - + @Resource private UserFunctionalPermissionContainersListGenerator functionalPermissionContainersListGenerator; - public UserRolesListGenerator( - UserFunctionalPermissionContainersListGenerator userFunctionalPermissionContainersListGenerator) - { - this.functionalPermissionContainersListGenerator = - userFunctionalPermissionContainersListGenerator; - } - public Collection generateRoles( Collection functionalPermissionContainers){ Collection authorities = new ArrayList<>(); diff --git a/src/main/java/com/codesdream/ase/component/UserTagsListGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UserTagsListGenerator.java similarity index 93% rename from src/main/java/com/codesdream/ase/component/UserTagsListGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UserTagsListGenerator.java index b3fca13..9b82847 100644 --- a/src/main/java/com/codesdream/ase/component/UserTagsListGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UserTagsListGenerator.java @@ -1,9 +1,9 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import com.codesdream.ase.model.permission.ScopePermissionContainer; import com.codesdream.ase.model.permission.Tag; import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.repository.UserRepository; +import com.codesdream.ase.repository.permission.UserRepository; import org.springframework.stereotype.Component; import javax.annotation.Resource; diff --git a/src/main/java/com/codesdream/ase/component/UsersListGenerator.java b/src/main/java/com/codesdream/ase/component/permission/UsersListGenerator.java similarity index 91% rename from src/main/java/com/codesdream/ase/component/UsersListGenerator.java rename to src/main/java/com/codesdream/ase/component/permission/UsersListGenerator.java index 6bbff53..db0abf1 100644 --- a/src/main/java/com/codesdream/ase/component/UsersListGenerator.java +++ b/src/main/java/com/codesdream/ase/component/permission/UsersListGenerator.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.component; +package com.codesdream.ase.component.permission; import com.codesdream.ase.model.permission.Tag; import com.codesdream.ase.model.permission.User; diff --git a/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java b/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java index a94c16b..32dd966 100644 --- a/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java +++ b/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java @@ -1,9 +1,8 @@ package com.codesdream.ase.configure; -import com.codesdream.ase.component.ASEPasswordEncoder; -import com.codesdream.ase.component.ASESecurityAuthenticationProvider; +import com.codesdream.ase.component.permission.ASEPasswordEncoder; +import com.codesdream.ase.component.permission.ASESecurityAuthenticationProvider; import com.codesdream.ase.service.ASEUserDetailsService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; diff --git a/src/main/java/com/codesdream/ase/controller/DataManagerController.java b/src/main/java/com/codesdream/ase/controller/DataManagerController.java new file mode 100644 index 0000000..9bde2db --- /dev/null +++ b/src/main/java/com/codesdream/ase/controller/DataManagerController.java @@ -0,0 +1,40 @@ +package com.codesdream.ase.controller; + +import org.apache.catalina.core.ApplicationContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.w3c.dom.Entity; + +import javax.annotation.Resource; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +@Controller +@RequestMapping(value = "/database") +public class DataManagerController { + + @RequestMapping(value = "{subSystem}/{dataModel}/query") + private String queryView(Model model, @PathVariable String dataModel, @PathVariable String subSystem) + throws InstantiationException, IllegalAccessException, ClassNotFoundException { + String dataModelFullName = "com.codesdream.ase.model." + subSystem + "." + dataModel; + String repositoryFullName = "com.codesdream.ase.repository." + subSystem + "." + dataModel + "Repository"; + try { + Class entityModelClass = Class.forName(dataModelFullName); + Collection paramArgs = new ArrayList<>(); + for(Field field :entityModelClass.getDeclaredFields()){ + paramArgs.add(field.getName()); + } + model.addAttribute("paramArgs", paramArgs); + Object entityModel = entityModelClass.newInstance(); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + throw e; + } + return null; + } +} diff --git a/src/main/java/com/codesdream/ase/model/information/BaseCandidateCategory.java b/src/main/java/com/codesdream/ase/model/information/BaseCandidateCategory.java new file mode 100644 index 0000000..e2e8d37 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/information/BaseCandidateCategory.java @@ -0,0 +1,20 @@ +package com.codesdream.ase.model.information; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 考生类别 + */ +@Data +@Entity +@Table(name = "base_candidate_category") +public class BaseCandidateCategory { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String name; + +} diff --git a/src/main/java/com/codesdream/ase/model/information/BaseCollege.java b/src/main/java/com/codesdream/ase/model/information/BaseCollege.java index 7bd9299..e62c514 100644 --- a/src/main/java/com/codesdream/ase/model/information/BaseCollege.java +++ b/src/main/java/com/codesdream/ase/model/information/BaseCollege.java @@ -16,4 +16,7 @@ public class BaseCollege { private int id; private String name; + + // 学院代码 + private int number; } diff --git a/src/main/java/com/codesdream/ase/model/information/BasePoliticalStatus.java b/src/main/java/com/codesdream/ase/model/information/BasePoliticalStatus.java new file mode 100644 index 0000000..1d5ef3c --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/information/BasePoliticalStatus.java @@ -0,0 +1,19 @@ +package com.codesdream.ase.model.information; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 政治面貌 + */ +@Data +@Entity +@Table(name = "base_political_status") +public class BasePoliticalStatus { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String name; +} diff --git a/src/main/java/com/codesdream/ase/model/information/BaseStudentInfo.java b/src/main/java/com/codesdream/ase/model/information/BaseStudentInfo.java new file mode 100644 index 0000000..f5e2c8f --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/information/BaseStudentInfo.java @@ -0,0 +1,42 @@ +package com.codesdream.ase.model.information; + +import lombok.Data; + +import javax.persistence.*; + +/** + * 学生基本真实信息 + */ +@Data +@Entity +@Table(name = "base_student_info") +public class BaseStudentInfo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + // 真实姓名 + private String name; + // 学号 + private String studentId; + // 班号 + private String classId; + // 性别 + private String sex; + // 民族 + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private BaseEthnic ethnic; + // 学院 + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private BaseCollege college; + // 专业 + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private BaseMajor major; + // 政治面貌 + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private BasePoliticalStatus politicalStatus; + // 省份地区 + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private BaseAdministrativeDivision administrativeDivision; + +} diff --git a/src/main/java/com/codesdream/ase/model/permission/User.java b/src/main/java/com/codesdream/ase/model/permission/User.java index 87b739c..6819bdc 100644 --- a/src/main/java/com/codesdream/ase/model/permission/User.java +++ b/src/main/java/com/codesdream/ase/model/permission/User.java @@ -1,15 +1,10 @@ package com.codesdream.ase.model.permission; -import com.codesdream.ase.component.UserAuthoritiesGenerator; -import com.codesdream.ase.component.UserRolesListGenerator; import com.codesdream.ase.model.activity.UserActivity; -import com.codesdream.ase.service.IUserService; import lombok.Data; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; -import javax.annotation.PostConstruct; -import javax.annotation.Resource; import javax.persistence.*; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/com/codesdream/ase/repository/information/BaseStudentInfoRepository.java b/src/main/java/com/codesdream/ase/repository/information/BaseStudentInfoRepository.java new file mode 100644 index 0000000..69f2d85 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/information/BaseStudentInfoRepository.java @@ -0,0 +1,14 @@ +package com.codesdream.ase.repository.information; + +import com.codesdream.ase.model.information.BaseStudentInfo; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface BaseStudentInfoRepository extends CrudRepository { + // 通过学号查找 + Optional findByStudentId(String student_id); + +} diff --git a/src/main/java/com/codesdream/ase/repository/FunctionalPermissionRepository.java b/src/main/java/com/codesdream/ase/repository/permission/FunctionalPermissionRepository.java similarity index 89% rename from src/main/java/com/codesdream/ase/repository/FunctionalPermissionRepository.java rename to src/main/java/com/codesdream/ase/repository/permission/FunctionalPermissionRepository.java index 5776b09..134b3f8 100644 --- a/src/main/java/com/codesdream/ase/repository/FunctionalPermissionRepository.java +++ b/src/main/java/com/codesdream/ase/repository/permission/FunctionalPermissionRepository.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.repository; +package com.codesdream.ase.repository.permission; import com.codesdream.ase.model.permission.FunctionalPermissionContainer; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/codesdream/ase/repository/PermissionContainersCollectionRepository.java b/src/main/java/com/codesdream/ase/repository/permission/PermissionContainersCollectionRepository.java similarity index 89% rename from src/main/java/com/codesdream/ase/repository/PermissionContainersCollectionRepository.java rename to src/main/java/com/codesdream/ase/repository/permission/PermissionContainersCollectionRepository.java index d0131a0..1b7b242 100644 --- a/src/main/java/com/codesdream/ase/repository/PermissionContainersCollectionRepository.java +++ b/src/main/java/com/codesdream/ase/repository/permission/PermissionContainersCollectionRepository.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.repository; +package com.codesdream.ase.repository.permission; import com.codesdream.ase.model.permission.PermissionContainersCollection; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/codesdream/ase/repository/ScopePermissionRepository.java b/src/main/java/com/codesdream/ase/repository/permission/ScopePermissionRepository.java similarity index 86% rename from src/main/java/com/codesdream/ase/repository/ScopePermissionRepository.java rename to src/main/java/com/codesdream/ase/repository/permission/ScopePermissionRepository.java index 984580a..95893f8 100644 --- a/src/main/java/com/codesdream/ase/repository/ScopePermissionRepository.java +++ b/src/main/java/com/codesdream/ase/repository/permission/ScopePermissionRepository.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.repository; +package com.codesdream.ase.repository.permission; import com.codesdream.ase.model.permission.ScopePermissionContainer; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/codesdream/ase/repository/TagRepository.java b/src/main/java/com/codesdream/ase/repository/permission/TagRepository.java similarity index 89% rename from src/main/java/com/codesdream/ase/repository/TagRepository.java rename to src/main/java/com/codesdream/ase/repository/permission/TagRepository.java index 9af0508..f46de40 100644 --- a/src/main/java/com/codesdream/ase/repository/TagRepository.java +++ b/src/main/java/com/codesdream/ase/repository/permission/TagRepository.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.repository; +package com.codesdream.ase.repository.permission; import com.codesdream.ase.model.permission.FunctionalPermissionContainer; import com.codesdream.ase.model.permission.Tag; diff --git a/src/main/java/com/codesdream/ase/repository/UserRepository.java b/src/main/java/com/codesdream/ase/repository/permission/UserRepository.java similarity index 88% rename from src/main/java/com/codesdream/ase/repository/UserRepository.java rename to src/main/java/com/codesdream/ase/repository/permission/UserRepository.java index 486beec..6ba5c8e 100644 --- a/src/main/java/com/codesdream/ase/repository/UserRepository.java +++ b/src/main/java/com/codesdream/ase/repository/permission/UserRepository.java @@ -1,4 +1,4 @@ -package com.codesdream.ase.repository; +package com.codesdream.ase.repository.permission; import com.codesdream.ase.model.permission.Tag; import com.codesdream.ase.model.permission.User; diff --git a/src/main/java/com/codesdream/ase/service/ASEUserDetailsService.java b/src/main/java/com/codesdream/ase/service/ASEUserDetailsService.java index 00e9ad8..411bcbb 100644 --- a/src/main/java/com/codesdream/ase/service/ASEUserDetailsService.java +++ b/src/main/java/com/codesdream/ase/service/ASEUserDetailsService.java @@ -1,6 +1,6 @@ package com.codesdream.ase.service; -import com.codesdream.ase.component.UserAuthoritiesGenerator; +import com.codesdream.ase.component.permission.UserAuthoritiesGenerator; import com.codesdream.ase.model.permission.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; @@ -9,7 +9,6 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.transaction.Transactional; -import java.util.Optional; @Service public class ASEUserDetailsService implements UserDetailsService { diff --git a/src/main/java/com/codesdream/ase/service/PermissionService.java b/src/main/java/com/codesdream/ase/service/PermissionService.java index 056a6c1..ee8f8f2 100644 --- a/src/main/java/com/codesdream/ase/service/PermissionService.java +++ b/src/main/java/com/codesdream/ase/service/PermissionService.java @@ -1,11 +1,11 @@ package com.codesdream.ase.service; -import com.codesdream.ase.component.UserFunctionalPermissionContainersListGenerator; -import com.codesdream.ase.component.UserFunctionalScopeRelationsListGenerator; +import com.codesdream.ase.component.permission.UserFunctionalPermissionContainersListGenerator; +import com.codesdream.ase.component.permission.UserFunctionalScopeRelationsListGenerator; import com.codesdream.ase.model.permission.*; -import com.codesdream.ase.repository.FunctionalPermissionRepository; -import com.codesdream.ase.repository.ScopePermissionRepository; -import com.codesdream.ase.repository.TagRepository; +import com.codesdream.ase.repository.permission.FunctionalPermissionRepository; +import com.codesdream.ase.repository.permission.ScopePermissionRepository; +import com.codesdream.ase.repository.permission.TagRepository; import javafx.util.Pair; import org.springframework.stereotype.Service; @@ -30,7 +30,7 @@ public class PermissionService implements IPermissionService { private UserFunctionalPermissionContainersListGenerator userFunctionalPermissionContainersListGenerator; @Resource - UserFunctionalScopeRelationsListGenerator userFunctionalScopeRelationsListGenerator; + private UserFunctionalScopeRelationsListGenerator userFunctionalScopeRelationsListGenerator; @Override public Optional findTag(String name) { diff --git a/src/main/java/com/codesdream/ase/service/UserService.java b/src/main/java/com/codesdream/ase/service/UserService.java index 45fb059..8c89180 100644 --- a/src/main/java/com/codesdream/ase/service/UserService.java +++ b/src/main/java/com/codesdream/ase/service/UserService.java @@ -1,10 +1,10 @@ package com.codesdream.ase.service; -import com.codesdream.ase.component.ASEPasswordEncoder; -import com.codesdream.ase.component.ASEUsernameEncoder; -import com.codesdream.ase.component.UserRolesListGenerator; +import com.codesdream.ase.component.permission.ASEPasswordEncoder; +import com.codesdream.ase.component.permission.ASEUsernameEncoder; +import com.codesdream.ase.component.permission.UserRolesListGenerator; import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.repository.UserRepository; +import com.codesdream.ase.repository.permission.UserRepository; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/codesdream/ase/test/DataManagerTest.java b/src/main/java/com/codesdream/ase/test/DataManagerTest.java new file mode 100644 index 0000000..49e4308 --- /dev/null +++ b/src/main/java/com/codesdream/ase/test/DataManagerTest.java @@ -0,0 +1,37 @@ +package com.codesdream.ase.test; + +import com.codesdream.ase.component.ASESpringUtil; +import com.codesdream.ase.component.datamanager.DataModelSearcher; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + + +@RunWith(SpringRunner.class) +@SpringBootTest +public class DataManagerTest { + @Resource + ASESpringUtil springUtil; + + @Test + public void dataModelSearcherTest() { + DataModelSearcher dataModelSearcher = springUtil.getBean(DataModelSearcher.class); + dataModelSearcher.getDataModelClass("permission", "Tag"); + Assert.assertTrue(dataModelSearcher.isPresent()); + + for(String param : dataModelSearcher.getDataModelParamArgs()){ + System.out.println(param); + } + + } + + @Test + public void dataModelRepositorySearcherTest(){ + + } + +} diff --git a/src/main/java/com/codesdream/ase/test/UserTest.java b/src/main/java/com/codesdream/ase/test/UserTest.java index 374123e..11f270b 100644 --- a/src/main/java/com/codesdream/ase/test/UserTest.java +++ b/src/main/java/com/codesdream/ase/test/UserTest.java @@ -3,7 +3,7 @@ package com.codesdream.ase.test; import com.codesdream.ase.model.permission.FunctionalPermissionContainer; import com.codesdream.ase.model.permission.Tag; import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.repository.UserRepository; +import com.codesdream.ase.repository.permission.UserRepository; import static org.junit.Assert.*; @@ -14,7 +14,6 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; import org.springframework.test.context.junit4.SpringRunner; -import java.util.HashMap; import java.util.HashSet; /**