234 lines
8.3 KiB
Java
234 lines
8.3 KiB
Java
package cd.casic.server.controller;
|
|
|
|
import cd.casic.ci.common.pipeline.req.pipeline.PipelineCreateReq;
|
|
import cd.casic.ci.common.pipeline.req.pipeline.PipelineQueryReq;
|
|
import cd.casic.ci.common.pipeline.req.pipeline.PipelineReq;
|
|
import cd.casic.ci.common.pipeline.resp.pipeline.PipelineResp;
|
|
import cd.casic.ci.process.process.service.pipeline.PipelineService;
|
|
import cd.casic.framework.commons.dataobject.User;
|
|
import cd.casic.framework.commons.pojo.CommonResult;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.security.PermitAll;
|
|
import jakarta.validation.Valid;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @ClassName PipelineController
|
|
* @Author hopeli
|
|
* @Date 2025/5/10 10:28
|
|
* @Version 1.0
|
|
*/
|
|
|
|
@RestController
|
|
@RequestMapping("/pipeline")
|
|
public class PipelineController {
|
|
|
|
@Resource
|
|
private PipelineService pipelineService;
|
|
|
|
@PermitAll
|
|
@PostMapping(path="/createPipeline")
|
|
public CommonResult<String> createPipeline(@RequestBody @Valid PipelineCreateReq pipelineReq){
|
|
|
|
String pipelineId = pipelineService.createPipeline(pipelineReq);
|
|
|
|
return CommonResult.success(pipelineId);
|
|
}
|
|
|
|
|
|
@PermitAll
|
|
@PostMapping(path="/findAllPipeline")
|
|
public CommonResult<List<PipelineResp>> findAllPipeline(){
|
|
|
|
// List<PipelineResp> selectAllPipeline = pipelineService.findAllPipeline();
|
|
|
|
List<PipelineResp> selectAllPipeline = new ArrayList<>(0);
|
|
return CommonResult.success(selectAllPipeline);
|
|
}
|
|
|
|
@PostMapping(path="/deletePipeline")
|
|
public CommonResult<Void> deletePipeline(@NotNull String pipelineId){
|
|
|
|
// pipelineService.deletePipeline(pipelineId);
|
|
|
|
return CommonResult.success();
|
|
}
|
|
|
|
@PostMapping(path="/findOnePipeline")
|
|
public CommonResult<List<PipelineResp>> findOnePipeline(@NotNull String pipelineId){
|
|
|
|
// Pipeline pipeline = pipelineService.findOnePipeline(pipelineId);
|
|
List<PipelineResp> pipelineRespList = new ArrayList<>(0);
|
|
PipelineResp pipeline = new PipelineResp();
|
|
pipeline.setId("1");
|
|
pipeline.setName("test数据交互测试");
|
|
pipelineRespList.add(pipeline);
|
|
|
|
return CommonResult.success(pipelineRespList);
|
|
}
|
|
|
|
@PostMapping(path="/findPipelineNoQuery")
|
|
public CommonResult<PipelineResp> findPipelineNoQuery(@NotNull String pipelineId){
|
|
|
|
// Pipeline pipeline = pipelineService.findPipelineNoQuery(pipelineId);
|
|
|
|
PipelineResp pipeline = new PipelineResp();
|
|
pipeline.setId("1");
|
|
pipeline.setName("test数据交互测试");
|
|
|
|
return CommonResult.success(pipeline);
|
|
}
|
|
|
|
// @RequestMapping(path="/updatePipelineRootUser",method = RequestMethod.POST)
|
|
// // @ApiMethod(name = "updatePipelineRootUser",desc = "更新流水线负责人")
|
|
// // @ApiParam(name = "dmRolePatch",desc = "流水线负责人信息",required = true)
|
|
// public Result<Void> updatePipelineRootUser(@RequestBody @NotNull @Valid DmRolePatch dmRolePatch){
|
|
//
|
|
// pipelineService.updatePipelineRootUser(dmRolePatch);
|
|
//
|
|
// return Result.ok();
|
|
// }
|
|
|
|
|
|
@PostMapping(path="/updatePipeline")
|
|
public CommonResult<Void> updatePipeline(@RequestBody @NotNull @Valid PipelineReq pipeline){
|
|
|
|
// pipelineService.updatePipeline(pipeline);
|
|
|
|
return CommonResult.success();
|
|
}
|
|
|
|
|
|
@PostMapping(path="/findUserPipelinePage")
|
|
public CommonResult<Page<PipelineResp>> findUserPipelinePage(@RequestBody @NotNull @Valid PipelineQueryReq query){
|
|
|
|
// Pagination<Pipeline> userPipeline = pipelineService.findUserPipelinePage(query);
|
|
Page<PipelineResp> pipelineRespPage = new Page<>();
|
|
List<PipelineResp> pipelineRespList = new ArrayList<>(0);
|
|
PipelineResp pipeline = new PipelineResp();
|
|
pipeline.setId("1");
|
|
pipeline.setName("test数据交互测试");
|
|
pipelineRespList.add(pipeline);
|
|
pipelineRespPage.setRecords(pipelineRespList);
|
|
return CommonResult.success(pipelineRespPage);
|
|
}
|
|
|
|
|
|
|
|
@PostMapping(path="/findUserPipeline")
|
|
public CommonResult<List<PipelineResp>> findAllUserPipeline(@RequestBody @NotNull @Valid PipelineQueryReq query){
|
|
// List<Pipeline> userPipeline = pipelineService.findUserPipeline(query);
|
|
|
|
List<PipelineResp> pipelineRespList = new ArrayList<>(0);
|
|
PipelineResp pipeline = new PipelineResp();
|
|
pipeline.setId("1");
|
|
pipeline.setName("test数据交互测试");
|
|
pipelineRespList.add(pipeline);
|
|
return CommonResult.success(pipelineRespList);
|
|
}
|
|
|
|
|
|
@PostMapping(path="/findPipelineUser")
|
|
public CommonResult<List<User>> findPipelineUser(@NotNull String pipelineId){
|
|
|
|
// List<User> dmUser = pipelineService.findPipelineUser(pipelineId);
|
|
List<User> userList = new ArrayList<>(0);
|
|
User user = new User();
|
|
user.setId("1");
|
|
user.setName("test数据交互测试");
|
|
userList.add(user);
|
|
return CommonResult.success(userList);
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping(path="/pipelineClone")
|
|
public CommonResult<Void> pipelineClone(@NotNull String pipelineId,@NotNull String pipelineName){
|
|
|
|
// pipelineService.pipelineClone(pipelineId,pipelineName);
|
|
|
|
return CommonResult.success();
|
|
}
|
|
|
|
@PostMapping(path="/findPipelineCloneName")
|
|
public CommonResult<String> findPipelineCloneName(@NotNull String pipelineId){
|
|
|
|
// String name = pipelineService.findPipelineCloneName(pipelineId);
|
|
String name = "test";
|
|
|
|
return CommonResult.success(name);
|
|
}
|
|
|
|
|
|
// /**
|
|
// * @pi.name:获取最近打开的流水线
|
|
// * @pi.url:/findRecentlyPipeline
|
|
// * @pi.methodType:post
|
|
// * @pi.request-type: formdata
|
|
// * @pi.param: name=number;dataType=Integer;value=查询数量;
|
|
// * @pi.param: name=pipelineId;dataType=String;value=流水线id;
|
|
// */
|
|
// @RequestMapping(path="/findRecentlyPipeline",method = RequestMethod.POST)
|
|
// public Result<String> findRecentlyPipeline(@NotNull Integer number,@NotNull String pipelineId){
|
|
//
|
|
// List<Pipeline> pipelineList = pipelineService.findRecentlyPipeline(number,pipelineId);
|
|
//
|
|
// return Result.ok(pipelineList);
|
|
// }
|
|
|
|
|
|
// /**
|
|
// * @pi.name:流水线导出为Yaml格式
|
|
// * @pi.url:/importPipelineYaml
|
|
// * @pi.methodType:post
|
|
// * @pi.request-type: formdata
|
|
// * @pi.param: name=request;dataType=HttpServletResponse;value=请求;
|
|
// * @pi.param: name=response;dataType=HttpServletRequest;value=请求体;
|
|
// */
|
|
// @RequestMapping(path="/importPipelineYaml",method = RequestMethod.POST)
|
|
// public ResponseEntity<Object> importPipelineYaml(HttpServletRequest request, HttpServletResponse response) {
|
|
// try {
|
|
// Map<String, String[]> parameterMap = request.getParameterMap();
|
|
//
|
|
// String pipelineId = Arrays.toString(parameterMap.get("pipelineId")).replace("[","").replace("]","");
|
|
//
|
|
// String yamlString = yamlService.importPipelineYaml(pipelineId);
|
|
//
|
|
// Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
|
//
|
|
// String tempFile = PipelineFileUtil.createTempFile(yamlString, ".yaml");
|
|
// File file = new File(tempFile);
|
|
// BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
|
|
//
|
|
// ServletOutputStream outputStream = response.getOutputStream();
|
|
// response.setHeader("Content-Disposition", "attachment; filename="+pipeline.getName());
|
|
// response.setContentLength((int) file.length());
|
|
//
|
|
// int buf_size = 1024;
|
|
// byte[] buffer = new byte[buf_size];
|
|
// int len = 0;
|
|
// while (-1 != (len = in.read(buffer, 0, buf_size))) {
|
|
// outputStream.write(buffer,0,len);
|
|
// }
|
|
// in.close();
|
|
// outputStream.close();
|
|
//
|
|
// file.delete();
|
|
//
|
|
// return ResponseEntity.ok().build();
|
|
// } catch (Exception e) {
|
|
// e.printStackTrace();
|
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Result.error(1000,"下载失败"));
|
|
// }
|
|
// }
|
|
}
|