| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package seecoder.devcloud.web.controller.pipeline;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import seecoder.devcloud.web.model.vo.Response;
- import seecoder.devcloud.web.model.vo.pipeline.PipelineConfigVO;
- import seecoder.devcloud.web.model.vo.pipeline.PipelineCreateVO;
- import seecoder.devcloud.web.model.vo.pipeline.PipelineHistoryVO;
- import seecoder.devcloud.web.model.vo.pipeline.PipelineInfoVO;
- import seecoder.devcloud.web.service.pipeline.PipelineService;
- import java.util.List;
- /**
- * @author PuHong Weng
- * @date 2021/3/11
- * @description:
- */
- @RestController
- @RequestMapping("/pipelines")
- @Api(tags = "流水线配置 API")
- public class PipelineController {
- private final PipelineService pipelineService;
- @Autowired
- public PipelineController(PipelineService pipelineService) {
- this.pipelineService = pipelineService;
- }
- @GetMapping("/list")
- @ApiOperation(value = "获取指定项目的所有流水线基本信息", httpMethod = "GET")
- @ApiImplicitParam(name = "projectId", dataType ="int",paramType = "query")
- public Response<List<PipelineInfoVO>> retrievePipelineInfos(@RequestParam("projectId") Integer projectId){
- return Response.buildSuccess(pipelineService.retrievePipelineInfos(projectId));
- }
- @GetMapping
- @ApiOperation(value = "获取指定一条流水线的配置json信息", httpMethod = "GET")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "projectId", dataType ="int",paramType = "query"),
- @ApiImplicitParam(name = "pipelineId", dataType ="int",paramType = "query")
- })
- public Response<PipelineConfigVO> retrievePipelineConfig(@RequestParam("projectId")Integer projectId,
- @RequestParam("pipelineId")Integer pipelineId){
- return Response.buildSuccess(pipelineService.retrievePipelineConfig(projectId, pipelineId));
- }
- @GetMapping("/history/list")
- @ApiOperation(value = "获取指定一条流水线的历史构建信息列表", httpMethod = "GET")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "projectId", dataType ="int",paramType = "query"),
- @ApiImplicitParam(name = "pipelineId", dataType ="int",paramType = "query")
- })
- public Response<List<PipelineHistoryVO>> retrievePipelineHistory(@RequestParam("projectId")Integer projectId,
- @RequestParam("pipelineId")Integer pipelineId){
- return Response.buildSuccess(pipelineService.retrievePipelineHistory(projectId,pipelineId));
- }
- @ApiOperation(value = "依据模板创建一个流水线配置", httpMethod = "POST")
- @ApiImplicitParam(name = "pipelineCreateVO", value = "流水线创建配置信息",dataType = "object",paramType = "body")
- @PostMapping
- public Response createPipelineConfig(@RequestBody @Validated PipelineCreateVO pipelineCreateVO){
- pipelineService.createPipelineConfig(pipelineCreateVO);
- return Response.buildSuccess();
- }
- @PutMapping("/config")
- @ApiOperation(value = "保存修改一条流水线的json配置信息", httpMethod = "PUT")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "projectId", dataType ="int",paramType = "query"),
- @ApiImplicitParam(name = "pipelineId", dataType ="int",paramType = "query"),
- @ApiImplicitParam(name = "configJson", dataType = "string",paramType = "query")
- })
- public Response savePipelineConfig(@RequestParam("projectId")Integer projectId,
- @RequestParam("pipelineId")Integer pipelineId,
- @RequestParam("configJson")String configJson){
- //todo 验证configJson有效性
- pipelineService.savePipelineConfig(projectId,pipelineId, configJson);
- return Response.buildSuccess();
- }
- @ApiOperation(value = "删除一条流水线", httpMethod = "DELETE")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "projectId", dataType ="int",paramType = "query"),
- @ApiImplicitParam(name = "pipelineId", dataType ="int",paramType = "query"),
- })
- @DeleteMapping
- public Response deletePipelineInfo(Integer projectId,Integer pipelineId){
- pipelineService.deletePipelineConfig(projectId, pipelineId);
- return Response.buildSuccess();
- }
- @ApiOperation(value = "获取可用的pipeline模板名字", httpMethod = "GET")
- @GetMapping("/templates")
- public Response<List<String>> getPipelineTemplateNames(){
- return Response.buildSuccess(pipelineService.getTemplateNames());
- }
- }
|