0516 ljc
This commit is contained in:
parent
734f44dfd3
commit
08ea03fd77
@ -0,0 +1,92 @@
|
||||
package cd.casic.ci.common.pipeline.utils;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页结果集
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2020/3/30 15:44
|
||||
*/
|
||||
@Data
|
||||
public class PageResult<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1L;
|
||||
|
||||
/**
|
||||
* 默认分页彩虹展示数量
|
||||
*/
|
||||
public static final int RAINBOW_NUM = 5;
|
||||
|
||||
/**
|
||||
* 第几页
|
||||
*/
|
||||
private Integer pageNo = 1;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize = 20;
|
||||
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private Integer totalPage = 0;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private Integer total = 0;
|
||||
|
||||
/**
|
||||
* 结果集
|
||||
*/
|
||||
private List<T> list;
|
||||
|
||||
/**
|
||||
* 分页彩虹
|
||||
*/
|
||||
private int[] rainbow;
|
||||
|
||||
public PageResult() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将mybatis-plus的page转成自定义的PageResult,扩展了totalPage总页数,和rainBow彩虹条
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2020/4/8 19:20
|
||||
*/
|
||||
public PageResult(Page<T> page) {
|
||||
this.setList(page.getRecords());
|
||||
this.setTotal(Convert.toInt(page.getTotal()));
|
||||
this.setPageNo(Convert.toInt(page.getCurrent()));
|
||||
this.setPageSize(Convert.toInt(page.getSize()));
|
||||
this.setRainbow(PageUtil.rainbow(Convert.toInt(page.getCurrent()),
|
||||
Convert.toInt(this.getTotalPage()), RAINBOW_NUM));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将mybatis-plus的page转成自定义的PageResult,扩展了totalPage总页数,和rainBow彩虹条
|
||||
* 可单独设置rows
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2020/4/14 20:55
|
||||
*/
|
||||
public PageResult(Page<T> page, List<T> t) {
|
||||
this.setList(t);
|
||||
this.setTotal(Convert.toInt(page.getTotal()));
|
||||
this.setPageNo(Convert.toInt(page.getCurrent()));
|
||||
this.setPageSize(Convert.toInt(page.getSize()));
|
||||
this.setTotalPage(PageUtil.totalPage(Convert.toInt(page.getTotal()),
|
||||
Convert.toInt(page.getSize())));
|
||||
this.setRainbow(PageUtil.rainbow(Convert.toInt(page.getCurrent()),
|
||||
Convert.toInt(this.getTotalPage()), RAINBOW_NUM));
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cd.casic.ci.process.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
public enum PiplineExecuteStatusEnum {
|
||||
DOC("1","资源申请中"),
|
||||
NEW_FEATURE("2","队列中"),
|
||||
INVALID("3","运行中"),
|
||||
NO_FIX("4","成功"),
|
||||
TEST_PASS("5","失败"),
|
||||
;
|
||||
private String code;
|
||||
private String msg;
|
||||
|
||||
PiplineExecuteStatusEnum(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
public static Map<String, PiplineExecuteStatusEnum> getCodeMap(){
|
||||
Map<String, PiplineExecuteStatusEnum> map = new HashMap<>();
|
||||
for (PiplineExecuteStatusEnum value : values()) {
|
||||
map.put(value.code, value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package cd.casic.ci.process.process.dataObject.pipeline;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
@ -5,8 +5,8 @@ import cd.casic.ci.common.pipeline.req.pipeline.PipelineQueryReq;
|
||||
import cd.casic.ci.common.pipeline.req.pipeline.PipelineReq;
|
||||
import cd.casic.ci.common.pipeline.req.pipeline.PipelineUpdateReq;
|
||||
import cd.casic.ci.common.pipeline.resp.pipeline.PipelineFindResp;
|
||||
import cd.casic.ci.common.pipeline.utils.PageResult;
|
||||
import cd.casic.ci.process.process.dataObject.pipeline.PipPipeline;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@ -28,7 +28,7 @@ public interface PipelineService extends IService<PipPipeline> {
|
||||
|
||||
void updatePipeline(@Valid PipelineUpdateReq pipeline);
|
||||
|
||||
Page<PipelineFindResp> findPipelinePage(@Valid PipelineQueryReq query);
|
||||
PageResult<PipelineFindResp> findPipelinePage(@Valid PipelineQueryReq query);
|
||||
|
||||
void pipelineClone(@Valid PipelineReq req);
|
||||
|
||||
|
@ -6,6 +6,7 @@ import cd.casic.ci.common.pipeline.req.pipeline.PipelineReq;
|
||||
import cd.casic.ci.common.pipeline.req.pipeline.PipelineUpdateReq;
|
||||
import cd.casic.ci.common.pipeline.resp.pipeline.PipelineFindResp;
|
||||
import cd.casic.ci.common.pipeline.resp.stage.StageResp;
|
||||
import cd.casic.ci.common.pipeline.utils.PageResult;
|
||||
import cd.casic.ci.process.process.converter.PipelineConverter;
|
||||
import cd.casic.ci.process.process.dal.pipeline.PipResourceDao;
|
||||
import cd.casic.ci.process.process.dal.pipeline.PipStageDao;
|
||||
@ -344,7 +345,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PipelineFindResp> findPipelinePage(PipelineQueryReq query) {
|
||||
public PageResult<PipelineFindResp> findPipelinePage(PipelineQueryReq query) {
|
||||
Page<PipelineFindResp> respPage = new Page<>();
|
||||
|
||||
QueryWrapper<PipPipeline> wrapper = new QueryWrapper<>();
|
||||
@ -369,7 +370,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
Page<PipPipeline> pipPipelinePage = pipelineDao.selectPage(new Page<>(query.getPageNo(), query.getPageSize()), wrapper);
|
||||
|
||||
if (ObjectUtils.isEmpty(pipPipelinePage)){
|
||||
return new Page<>();
|
||||
return new PageResult<>();
|
||||
}
|
||||
|
||||
List<PipelineFindResp> respList = PipelineConverter.INSTANCE.toRespList(pipPipelinePage.getRecords());
|
||||
@ -377,7 +378,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
//对流水线进行流水线信息赋值
|
||||
respList.forEach(this::setStageAndTask);
|
||||
respPage.setRecords(respList);
|
||||
return respPage;
|
||||
PageResult<PipelineFindResp> pageResult = new PageResult<>(respPage);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,9 +5,9 @@ import cd.casic.ci.common.pipeline.req.pipeline.PipelineQueryReq;
|
||||
import cd.casic.ci.common.pipeline.req.pipeline.PipelineReq;
|
||||
import cd.casic.ci.common.pipeline.req.pipeline.PipelineUpdateReq;
|
||||
import cd.casic.ci.common.pipeline.resp.pipeline.PipelineFindResp;
|
||||
import cd.casic.ci.common.pipeline.utils.PageResult;
|
||||
import cd.casic.ci.process.process.service.pipeline.PipelineService;
|
||||
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;
|
||||
@ -80,9 +80,9 @@ public class PipelineController {
|
||||
|
||||
|
||||
@PostMapping(path="/findPipelinePage")
|
||||
public CommonResult<Page<PipelineFindResp>> findPipelinePage(@RequestBody @NotNull @Valid PipelineQueryReq query){
|
||||
public CommonResult<PageResult<PipelineFindResp>> findPipelinePage(@RequestBody @NotNull @Valid PipelineQueryReq query){
|
||||
|
||||
Page<PipelineFindResp> pipelineRespPage = pipelineService.findPipelinePage(query);
|
||||
PageResult<PipelineFindResp> pipelineRespPage = pipelineService.findPipelinePage(query);
|
||||
|
||||
return CommonResult.success(pipelineRespPage);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user