|
|
package com.monitor.other.worksystem.dock;
|
|
|
package com.monitor.other.worksystem.ctrl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.model.ReleaseWorkJob;
|
|
|
import com.model.DockerProjectModel;
|
|
|
import com.monitor.model.request.DockerJenkinsReq;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.monitor.other.worksystem.dock.qq.DockerServerDeployService;
|
|
|
import com.monitor.other.worksystem.service.ReleaseService;
|
|
|
import com.monitor.other.worksystem.service.DockerProjectService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/work/docker")
|
|
|
public class DockerServerDeployCtrl {
|
|
|
@RequestMapping("/dockerProject")
|
|
|
public class DockerProjectCtrl {
|
|
|
|
|
|
@Autowired
|
|
|
private ReleaseService releaseService;
|
|
|
private DockerProjectService dockerProjectService;
|
|
|
|
|
|
@Autowired
|
|
|
private DockerServerDeployService dockerServerDeployService;
|
|
|
|
|
|
/**
|
|
|
* 查询docker项目
|
|
|
*/
|
|
|
@RequestMapping("/getDockerProjectByType")
|
|
|
@ResponseBody
|
|
|
public BaseResponse<List<DockerProjectModel>> getDockerProjectByType(String projectType) {
|
|
|
return new BaseResponse<>(dockerProjectService.selectByProjectType(projectType));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询docker项目
|
|
|
*/
|
|
|
@RequestMapping("/getDockerProjectByIds")
|
|
|
@ResponseBody
|
|
|
public BaseResponse<List<DockerProjectModel>> getDockerProjectByIds(String ids) {
|
|
|
List<Integer> idList=new ArrayList<>();
|
|
|
for(String id:ids.split(",")){
|
|
|
if(StringUtils.isNotBlank(id)){
|
|
|
idList.add(Integer.parseInt(id.trim()));
|
|
|
}
|
|
|
}
|
|
|
return new BaseResponse<>(dockerProjectService.selectByIdList(idList));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布工单_jenkins:发起镜像制作
|
|
|
*/
|
|
|
@RequestMapping("/createMirror")
|
|
|
@ResponseBody
|
|
|
public BaseResponse createMirror() {
|
|
|
ReleaseWorkJob releaseWorkJob=new ReleaseWorkJob();
|
|
|
int jobId=releaseService.jenkinsBuild(releaseWorkJob);
|
|
|
public BaseResponse createMirror(@RequestBody DockerJenkinsReq dockerJenkinsReq) {
|
|
|
String id=dockerProjectService.jenkinsBuild(dockerJenkinsReq);
|
|
|
BaseResponse rnt=new BaseResponse();
|
|
|
if(id==null||id.length()<=0){
|
|
|
rnt.setCode(201);
|
|
|
rnt.setMessage("请求镜像失败,返回jobId = " +id);
|
|
|
}else{
|
|
|
rnt.setData(id);
|
|
|
}
|
|
|
return rnt;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布工单_jenkins:更新镜像的状态
|
|
|
*/
|
|
|
@RequestMapping("/updateJenkinsStatus")
|
|
|
@ResponseBody
|
|
|
public BaseResponse updateJenkinsStatus(String ticketID,String jobID,String status) {
|
|
|
dockerProjectService.jenkinsStatusUpdate(ticketID,jobID,status);
|
|
|
BaseResponse rnt=new BaseResponse();
|
|
|
rnt.setData(jobId);
|
|
|
return rnt;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发布工单_jenkins:更新镜像的状态
|
|
|
*/
|
|
|
@RequestMapping("/queryJenkinsStatus")
|
|
|
@ResponseBody
|
|
|
public BaseResponse queryJenkinsStatus(String ticketID,String jobID,String status) {
|
|
|
dockerProjectService.jenkinsStatusUpdate(ticketID,jobID,status);
|
|
|
BaseResponse rnt=new BaseResponse();
|
|
|
return rnt;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 发布docker服务
|
|
|
*/
|
|
|
@RequestMapping("/deployMirror")
|
...
|
...
|
|