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.dataObject.log.PipTaskLogLine;
import cd.casic.ci.process.process.service.history.PipelineHistoryService;
import cd.casic.ci.process.process.service.taskLog.PipTaskLogLineService;
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.*;

import java.util.List;

@RestController
@RequestMapping("/history")
public class PipHistoryController {
    @Resource
    private PipelineHistoryService pipelineHistoryService;
    @Resource
    private PipTaskLogLineService logLineService;
    @GetMapping("/getLogById")
    public CommonResult<String> getLogById(@RequestParam String id){
        String content = logLineService.getLineContentByLogId(id, 10000);
        return CommonResult.success(content);
    }
    @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));
    }
}
