Authored by LUOXC

refactor

... ... @@ -6,72 +6,44 @@ import java.util.*;
public class ProjectEnvironment {
//private static String[] dockerProjectTypes = {"node","java","php","ops","other"};
private static Map<String,String> map = new HashMap<>();
//docker相关
private static Map<String,String> dockerProjectTypeMap=new LinkedHashMap<>();
//项目发布的方式
private static Map<String,String> projectDeployTypeMap=new LinkedHashMap<>();
static{
map.put("aws", "http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");
map.put("qcloud","http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");
map.put("qcloud_gray","http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");
map.put("aws_gray","http://"+ ProjectConstant.DEPLOY_IP+":8883/web/");
initDockerProjectTypeMap();
projectDeployTypeMap.put("git","git分支");
projectDeployTypeMap.put("image","镜像文件");
}
private static void initDockerProjectTypeMap() {
dockerProjectTypeMap.put("web","web");
dockerProjectTypeMap.put("media","media");
dockerProjectTypeMap.put("java","java");
dockerProjectTypeMap.put("ops","ops");
dockerProjectTypeMap.put("erp","erp");
dockerProjectTypeMap.put("jenkins-deploy","jenkins-deploy");
}
public static String getUrl(String envi){
if(map.containsKey(envi)){
return map.get(envi);
}else{
return "http://"+ ProjectConstant.DEPLOY_IP+":8883/web/";
}
}
public static List<String> getDockerEnvironments(String projectName) {
if (projectName == null
|| projectName.contains("yohobuywap-node")
|| projectName.contains("yoho-community-web")
|| projectName.contains("yohobuy-node")
|| projectName.contains("ufo-app-web")
|| projectName.contains("yoho-app-web")
|| projectName.contains("ultrainBlockApi")
|| projectName.contains("yohobuywap-node-activity")
|| projectName.contains("xianyu-ufo-app-web")
|| projectName.contains("xianyuservice")
|| projectName.contains("yoho-shop-manage")) {
return Arrays.asList("yoho-online","yoho-gray");
} else {
return Arrays.asList("yoho-online");
}
}
public static Map<String,String> getDockerProjectTypeMap(){
return dockerProjectTypeMap;
}
public static Map<String,String> getProjectDeployTypeMap(){
return projectDeployTypeMap;
}
public static String getUrl(String envi) {
return "http://" + ProjectConstant.DEPLOY_IP + ":8883/web/";
}
public static List<String> dockerEnvironments(String projectName) {
if (projectName == null
|| projectName.contains("yohobuywap-node")
|| projectName.contains("yoho-community-web")
|| projectName.contains("yohobuy-node")
|| projectName.contains("ufo-app-web")
|| projectName.contains("yoho-app-web")
|| projectName.contains("ultrainBlockApi")
|| projectName.contains("yohobuywap-node-activity")
|| projectName.contains("xianyu-ufo-app-web")
|| projectName.contains("xianyuservice")
|| projectName.contains("yoho-shop-manage")) {
return Arrays.asList("yoho-online", "yoho-gray");
} else {
return Arrays.asList("yoho-online");
}
}
public static Map<String, String> dockerProjectTypes() {
Map<String, String> dockerProjectTypeMap = new LinkedHashMap<>();
dockerProjectTypeMap.put("web", "web");
dockerProjectTypeMap.put("media", "media");
dockerProjectTypeMap.put("java", "java");
dockerProjectTypeMap.put("ops", "ops");
dockerProjectTypeMap.put("erp", "erp");
dockerProjectTypeMap.put("jenkins-deploy", "jenkins-deploy");
return dockerProjectTypeMap;
}
public static Map<String, String> getProjectDeployTypeMap() {
Map<String, String> projectDeployTypeMap = new LinkedHashMap<>();
projectDeployTypeMap.put("git", "git分支");
projectDeployTypeMap.put("image", "镜像文件");
return projectDeployTypeMap;
}
}
... ...
... ... @@ -27,7 +27,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@RestController
... ... @@ -89,8 +88,8 @@ public class DockerBuildCtrl {
}
}
model.addAttribute("clusters", JSON.toJSONString(this.getDockerClusterMap()));
model.addAttribute("environments", ProjectEnvironment.getDockerEnvironments(null));
model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap());
model.addAttribute("environments", ProjectEnvironment.dockerEnvironments(null));
model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
return new ModelAndView("project/docker_project");
}
... ... @@ -417,7 +416,7 @@ public class DockerBuildCtrl {
@RequestMapping(value = "/toDockerInfoList")
public ModelAndView toDockerInfoList(Model model,DockerJenkinsReq dockerJenkinsReq) {
model.addAttribute("clusters", JSON.toJSONString(this.getDockerClusterMap()));
model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap());
model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
model.addAttribute("projectJobTypes", httpRestClient.defaultGet("/dockerProject/getDockerProjectJobType",BaseResponse.class).getData());
return new ModelAndView("project/docker_info");
}
... ... @@ -439,7 +438,7 @@ public class DockerBuildCtrl {
@RequestMapping("/toEditDockerInfo")
public ModelAndView toEditDockerInfos(Model model) {
model.addAttribute("clusters", this.getDockerClusterMap());
model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap());
model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
model.addAttribute("projectJobTypes", httpRestClient.defaultGet("/dockerProject/getDockerProjectJobType",BaseResponse.class).getData());
return new ModelAndView("project/editDockerInfo");
... ...
... ... @@ -61,8 +61,8 @@ public class WorkSystemCtrl {
public ModelAndView toAddWork(Model model) {
model.addAttribute("platforms", Platform.getPlatforms());
//model.addAttribute("dockerEnvironments", ProjectEnvironment.getDockerEnvironments(null));
model.addAttribute("projectTypes", ProjectEnvironment.getDockerProjectTypeMap());
//model.addAttribute("dockerEnvironments", ProjectEnvironment.dockerEnvironments(null));
model.addAttribute("projectTypes", ProjectEnvironment.dockerProjectTypes());
model.addAttribute("projectDeployTypes", ProjectEnvironment.getProjectDeployTypeMap());
BaseResponse<List<User>> resp = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
}, null);
... ... @@ -185,7 +185,7 @@ public class WorkSystemCtrl {
}
}
} else if (Platform.DOCKER.equals(platform)) {
envs.addAll(ProjectEnvironment.getDockerEnvironments(projects));
envs.addAll(ProjectEnvironment.dockerEnvironments(projects));
}
return envs;
}
... ...