From 3706d2e1db45e64a1375b92300901de39e35e464 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期二, 25 一月 2022 21:50:54 +0800 Subject: [PATCH] update 去除链式调用注解 不符合规范导致很多奇葩问题 例如: copy为空问题 --- ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java | 90 +++++++++++++++++++++++++++++---------------- 1 files changed, 58 insertions(+), 32 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java index 81c596b..48353e3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java @@ -1,5 +1,7 @@ package com.ruoyi.common.core.page; +import cn.hutool.http.HttpStatus; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -17,44 +19,68 @@ @Data @NoArgsConstructor -@Accessors(chain = true) @ApiModel("鍒嗛〉鍝嶅簲瀵硅薄") public class TableDataInfo<T> implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * 鎬昏褰曟暟 - */ - @ApiModelProperty("鎬昏褰曟暟") - private long total; + /** + * 鎬昏褰曟暟 + */ + @ApiModelProperty("鎬昏褰曟暟") + private long total; - /** - * 鍒楄〃鏁版嵁 - */ - @ApiModelProperty("鍒楄〃鏁版嵁") - private List<T> rows; + /** + * 鍒楄〃鏁版嵁 + */ + @ApiModelProperty("鍒楄〃鏁版嵁") + private List<T> rows; - /** - * 娑堟伅鐘舵�佺爜 - */ - @ApiModelProperty("娑堟伅鐘舵�佺爜") - private int code; + /** + * 娑堟伅鐘舵�佺爜 + */ + @ApiModelProperty("娑堟伅鐘舵�佺爜") + private int code; - /** - * 娑堟伅鍐呭 - */ - @ApiModelProperty("娑堟伅鍐呭") - private String msg; + /** + * 娑堟伅鍐呭 + */ + @ApiModelProperty("娑堟伅鍐呭") + private String msg; - /** - * 鍒嗛〉 - * - * @param list 鍒楄〃鏁版嵁 - * @param total 鎬昏褰曟暟 - */ - public TableDataInfo(List<T> list, long total) { - this.rows = list; - this.total = total; - } + /** + * 鍒嗛〉 + * + * @param list 鍒楄〃鏁版嵁 + * @param total 鎬昏褰曟暟 + */ + public TableDataInfo(List<T> list, long total) { + this.rows = list; + this.total = total; + } + + public static <T> TableDataInfo<T> build(IPage<T> page) { + TableDataInfo<T> rspData = new TableDataInfo<>(); + rspData.setCode(HttpStatus.HTTP_OK); + rspData.setMsg("鏌ヨ鎴愬姛"); + rspData.setRows(page.getRecords()); + rspData.setTotal(page.getTotal()); + return rspData; + } + + public static <T> TableDataInfo<T> build(List<T> list) { + TableDataInfo<T> rspData = new TableDataInfo<>(); + rspData.setCode(HttpStatus.HTTP_OK); + rspData.setMsg("鏌ヨ鎴愬姛"); + rspData.setRows(list); + rspData.setTotal(list.size()); + return rspData; + } + + public static <T> TableDataInfo<T> build() { + TableDataInfo<T> rspData = new TableDataInfo<>(); + rspData.setCode(HttpStatus.HTTP_OK); + rspData.setMsg("鏌ヨ鎴愬姛"); + return rspData; + } } -- Gitblit v1.9.3