|
@@ -1,5 +1,8 @@
|
|
|
package com.mooctest.crowd.site.configuration;
|
|
|
|
|
|
+import com.mooctest.crowd.domain.domainobject.ApplicationType;
|
|
|
+import com.mooctest.crowd.domain.domainobject.Field;
|
|
|
+import com.mooctest.crowd.domain.domainobject.TestType;
|
|
|
import com.mooctest.crowd.domain.repository.CommonRepo;
|
|
|
import lombok.Data;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -11,6 +14,7 @@ import javax.annotation.PreDestroy;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author guochao
|
|
@@ -19,6 +23,9 @@ import java.util.Map;
|
|
|
@Data
|
|
|
@Component
|
|
|
public class DataCache {
|
|
|
+ private List<Field> fieldList;
|
|
|
+ private List<ApplicationType> applicationList;
|
|
|
+ private List<TestType> typeList;
|
|
|
private Map<String, String> fieldMap;
|
|
|
private Map<String, String> applicationTypeMap;
|
|
|
private Map<String, String> testTypeMap;
|
|
@@ -33,13 +40,32 @@ public class DataCache {
|
|
|
public void init() {
|
|
|
// 系统启动时加载Map,每次运行初始化
|
|
|
// 获取领域、应用、测试类型code 和 name 的map
|
|
|
- Map<String, String> fieldMapTemp = commonRepo.getFieldCodeNameMap();
|
|
|
- Map<String, String> applicationTypeMapTemp = commonRepo.getApplicationCodeNameMap();
|
|
|
- Map<String, String> testTypeMapTemp = commonRepo.getTypeCodeNameMap();
|
|
|
+ List<Field> fieldList = commonRepo.getFieldList();
|
|
|
+ List<ApplicationType> applicationList = commonRepo.getApplicationList();
|
|
|
+ List<TestType> typeList = commonRepo.getTypeList();
|
|
|
+ Map<String, String> fieldMapTemp = fieldList.stream().collect(Collectors.toMap(field -> field.getCode(), field -> field.getName()));
|
|
|
+ Map<String, String> applicationTypeMapTemp = applicationList.stream().collect(Collectors.toMap(applicationType -> applicationType.getCode(), applicationType -> applicationType.getName()));
|
|
|
+ Map<String, String> testTypeMapTemp = typeList.stream().collect(Collectors.toMap(testType -> testType.getCode(), testType -> testType.getName()));
|
|
|
+
|
|
|
Map<String, List<String>> fieldToAppMapTemp = new HashMap();
|
|
|
Map<String, List<String>> appToTestTypeMapTemp = new HashMap();
|
|
|
Map<String, String> testTypeCodeToNameMapTemp = new HashMap();
|
|
|
|
|
|
+ if(this.fieldList != null) {
|
|
|
+ this.fieldList.clear();
|
|
|
+ }
|
|
|
+ this.fieldList = fieldList;
|
|
|
+
|
|
|
+ if(this.applicationList != null) {
|
|
|
+ this.applicationList.clear();
|
|
|
+ }
|
|
|
+ this.applicationList = applicationList;
|
|
|
+
|
|
|
+ if(this.typeList != null) {
|
|
|
+ this.typeList.clear();
|
|
|
+ }
|
|
|
+ this.typeList = typeList;
|
|
|
+
|
|
|
// 获取所有领域类型信息
|
|
|
if(this.fieldMap != null) {
|
|
|
this.fieldMap.clear();
|