package cd.casic.ci.api;

import cd.casic.ci.process.dto.req.history.PipelineHistoryQueryReq;
import cd.casic.ci.process.process.dataObject.history.PipPipelineHisInstance;
import cd.casic.ci.process.process.dataObject.log.PipTaskLog;
import cd.casic.ci.process.process.service.history.PipelineHistoryService;
import cd.casic.ci.process.process.service.taskLog.TaskLogService;
import cd.casic.framework.commons.pojo.CommonResult;
import cd.casic.framework.commons.pojo.PageResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/history")
public class PipHistoryController {
    @Resource
    TaskLogService taskLogService;
    @Resource
    PipelineHistoryService pipelineHistoryService;
    @GetMapping("/getLogById")
    public CommonResult<PipTaskLog> getLogById(String id){
        PipTaskLog byId = taskLogService.getById(id);
        return CommonResult.success(byId);
    }
    @PostMapping("/list")
    public CommonResult<PageResult<PipPipelineHisInstance>> list(@RequestBody PipelineHistoryQueryReq req){
        return CommonResult.success(pipelineHistoryService.getPageByPipelineId(req));
    }
    @PostMapping("/getById/{id}")
    public CommonResult<PipPipelineHisInstance> getById(@PathVariable String id){
        return CommonResult.success(pipelineHistoryService.getById(id));
    }
}
