Authored by LUOXC

refactor

@@ -6,72 +6,44 @@ import java.util.*; @@ -6,72 +6,44 @@ import java.util.*;
6 6
7 public class ProjectEnvironment { 7 public class ProjectEnvironment {
8 8
9 - //private static String[] dockerProjectTypes = {"node","java","php","ops","other"};  
10 - private static Map<String,String> map = new HashMap<>();  
11 -  
12 - //docker相关  
13 - private static Map<String,String> dockerProjectTypeMap=new LinkedHashMap<>();  
14 -  
15 - //项目发布的方式  
16 - private static Map<String,String> projectDeployTypeMap=new LinkedHashMap<>();  
17 -  
18 - static{  
19 - map.put("aws", "http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");  
20 - map.put("qcloud","http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");  
21 - map.put("qcloud_gray","http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");  
22 - map.put("aws_gray","http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");  
23 -  
24 - initDockerProjectTypeMap();  
25 -  
26 - projectDeployTypeMap.put("git","git分支");  
27 - projectDeployTypeMap.put("image","镜像文件");  
28 -  
29 - }  
30 -  
31 - private static void initDockerProjectTypeMap() {  
32 - dockerProjectTypeMap.put("web","web");  
33 - dockerProjectTypeMap.put("media","media");  
34 - dockerProjectTypeMap.put("java","java");  
35 - dockerProjectTypeMap.put("ops","ops");  
36 - dockerProjectTypeMap.put("erp","erp");  
37 - dockerProjectTypeMap.put("jenkins-deploy","jenkins-deploy");  
38 - }  
39 -  
40 -  
41 - public static String getUrl(String envi){  
42 - if(map.containsKey(envi)){  
43 - return map.get(envi);  
44 - }else{  
45 - return "http://"+ ProjectConstant.DEPLOY_IP+":8883/web/";  
46 - }  
47 - }  
48 -  
49 -  
50 - public static List<String> getDockerEnvironments(String projectName) {  
51 - if (projectName == null  
52 - || projectName.contains("yohobuywap-node")  
53 - || projectName.contains("yoho-community-web")  
54 - || projectName.contains("yohobuy-node")  
55 - || projectName.contains("ufo-app-web")  
56 - || projectName.contains("yoho-app-web")  
57 - || projectName.contains("ultrainBlockApi")  
58 - || projectName.contains("yohobuywap-node-activity")  
59 - || projectName.contains("xianyu-ufo-app-web")  
60 - || projectName.contains("xianyuservice")  
61 - || projectName.contains("yoho-shop-manage")) {  
62 - return Arrays.asList("yoho-online","yoho-gray");  
63 - } else {  
64 - return Arrays.asList("yoho-online");  
65 - }  
66 - }  
67 -  
68 - public static Map<String,String> getDockerProjectTypeMap(){  
69 - return dockerProjectTypeMap;  
70 - }  
71 -  
72 - public static Map<String,String> getProjectDeployTypeMap(){  
73 - return projectDeployTypeMap;  
74 - }  
75 - 9 + public static String getUrl(String envi) {
  10 + return "http://" + ProjectConstant.DEPLOY_IP + ":8883/web/";
  11 + }
  12 +
  13 + public static List<String> dockerEnvironments(String projectName) {
  14 + if (projectName == null
  15 + || projectName.contains("yohobuywap-node")
  16 + || projectName.contains("yoho-community-web")
  17 + || projectName.contains("yohobuy-node")
  18 + || projectName.contains("ufo-app-web")
  19 + || projectName.contains("yoho-app-web")
  20 + || projectName.contains("ultrainBlockApi")
  21 + || projectName.contains("yohobuywap-node-activity")
  22 + || projectName.contains("xianyu-ufo-app-web")
  23 + || projectName.contains("xianyuservice")
  24 + || projectName.contains("yoho-shop-manage")) {
  25 + return Arrays.asList("yoho-online", "yoho-gray");
  26 + } else {
  27 + return Arrays.asList("yoho-online");
  28 + }
  29 + }
  30 +
  31 + public static Map<String, String> dockerProjectTypes() {
  32 + Map<String, String> dockerProjectTypeMap = new LinkedHashMap<>();
  33 + dockerProjectTypeMap.put("web", "web");
  34 + dockerProjectTypeMap.put("media", "media");
  35 + dockerProjectTypeMap.put("java", "java");
  36 + dockerProjectTypeMap.put("ops", "ops");
  37 + dockerProjectTypeMap.put("erp", "erp");
  38 + dockerProjectTypeMap.put("jenkins-deploy", "jenkins-deploy");
  39 + return dockerProjectTypeMap;
  40 + }
  41 +
  42 + public static Map<String, String> getProjectDeployTypeMap() {
  43 + Map<String, String> projectDeployTypeMap = new LinkedHashMap<>();
  44 + projectDeployTypeMap.put("git", "git分支");
  45 + projectDeployTypeMap.put("image", "镜像文件");
  46 + return projectDeployTypeMap;
  47 + }
76 48
77 } 49 }
@@ -27,7 +27,6 @@ import java.util.ArrayList; @@ -27,7 +27,6 @@ import java.util.ArrayList;
27 import java.util.HashMap; 27 import java.util.HashMap;
28 import java.util.List; 28 import java.util.List;
29 import java.util.Map; 29 import java.util.Map;
30 -import java.util.concurrent.CompletableFuture;  
31 30
32 31
33 @RestController 32 @RestController
@@ -89,8 +88,8 @@ public class DockerBuildCtrl { @@ -89,8 +88,8 @@ public class DockerBuildCtrl {
89 } 88 }
90 } 89 }
91 model.addAttribute("clusters", JSON.toJSONString(this.getDockerClusterMap())); 90 model.addAttribute("clusters", JSON.toJSONString(this.getDockerClusterMap()));
92 - model.addAttribute("environments", ProjectEnvironment.getDockerEnvironments(null));  
93 - model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap()); 91 + model.addAttribute("environments", ProjectEnvironment.dockerEnvironments(null));
  92 + model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
94 model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap()); 93 model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
95 return new ModelAndView("project/docker_project"); 94 return new ModelAndView("project/docker_project");
96 } 95 }
@@ -417,7 +416,7 @@ public class DockerBuildCtrl { @@ -417,7 +416,7 @@ public class DockerBuildCtrl {
417 @RequestMapping(value = "/toDockerInfoList") 416 @RequestMapping(value = "/toDockerInfoList")
418 public ModelAndView toDockerInfoList(Model model,DockerJenkinsReq dockerJenkinsReq) { 417 public ModelAndView toDockerInfoList(Model model,DockerJenkinsReq dockerJenkinsReq) {
419 model.addAttribute("clusters", JSON.toJSONString(this.getDockerClusterMap())); 418 model.addAttribute("clusters", JSON.toJSONString(this.getDockerClusterMap()));
420 - model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap()); 419 + model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
421 model.addAttribute("projectJobTypes", httpRestClient.defaultGet("/dockerProject/getDockerProjectJobType",BaseResponse.class).getData()); 420 model.addAttribute("projectJobTypes", httpRestClient.defaultGet("/dockerProject/getDockerProjectJobType",BaseResponse.class).getData());
422 return new ModelAndView("project/docker_info"); 421 return new ModelAndView("project/docker_info");
423 } 422 }
@@ -439,7 +438,7 @@ public class DockerBuildCtrl { @@ -439,7 +438,7 @@ public class DockerBuildCtrl {
439 @RequestMapping("/toEditDockerInfo") 438 @RequestMapping("/toEditDockerInfo")
440 public ModelAndView toEditDockerInfos(Model model) { 439 public ModelAndView toEditDockerInfos(Model model) {
441 model.addAttribute("clusters", this.getDockerClusterMap()); 440 model.addAttribute("clusters", this.getDockerClusterMap());
442 - model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap()); 441 + model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
443 model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap()); 442 model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
444 model.addAttribute("projectJobTypes", httpRestClient.defaultGet("/dockerProject/getDockerProjectJobType",BaseResponse.class).getData()); 443 model.addAttribute("projectJobTypes", httpRestClient.defaultGet("/dockerProject/getDockerProjectJobType",BaseResponse.class).getData());
445 return new ModelAndView("project/editDockerInfo"); 444 return new ModelAndView("project/editDockerInfo");
@@ -61,8 +61,8 @@ public class WorkSystemCtrl { @@ -61,8 +61,8 @@ public class WorkSystemCtrl {
61 public ModelAndView toAddWork(Model model) { 61 public ModelAndView toAddWork(Model model) {
62 62
63 model.addAttribute("platforms", Platform.getPlatforms()); 63 model.addAttribute("platforms", Platform.getPlatforms());
64 - //model.addAttribute("dockerEnvironments", ProjectEnvironment.getDockerEnvironments(null));  
65 - model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap()); 64 + //model.addAttribute("dockerEnvironments", ProjectEnvironment.dockerEnvironments(null));
  65 + model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
66 model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap()); 66 model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
67 BaseResponse<List<User>> resp = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() { 67 BaseResponse<List<User>> resp = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
68 }, null); 68 }, null);
@@ -185,7 +185,7 @@ public class WorkSystemCtrl { @@ -185,7 +185,7 @@ public class WorkSystemCtrl {
185 } 185 }
186 } 186 }
187 } else if (Platform.DOCKER.equals(platform)) { 187 } else if (Platform.DOCKER.equals(platform)) {
188 - envs.addAll(ProjectEnvironment.getDockerEnvironments(projects)); 188 + envs.addAll(ProjectEnvironment.dockerEnvironments(projects));
189 } 189 }
190 return envs; 190 return envs;
191 } 191 }