| | |
| | | package com.ruoyi.common.core.page;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * 表格分页数据对象
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class TableDataInfo implements Serializable
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | /** 总记录数 */
|
| | | private long total;
|
| | |
|
| | | /** 列表数据 */
|
| | | private List<?> rows;
|
| | |
|
| | | /** 消息状态码 */
|
| | | private int code;
|
| | |
|
| | | /** 消息内容 */
|
| | | private String msg;
|
| | |
|
| | | /**
|
| | | * 表格数据对象
|
| | | */
|
| | | public TableDataInfo()
|
| | | {
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分页
|
| | | * |
| | | * @param list 列表数据
|
| | | * @param total 总记录数
|
| | | */
|
| | | public TableDataInfo(List<?> list, int total)
|
| | | {
|
| | | this.rows = list;
|
| | | this.total = total;
|
| | | }
|
| | |
|
| | | public long getTotal()
|
| | | {
|
| | | return total;
|
| | | }
|
| | |
|
| | | public void setTotal(long total)
|
| | | {
|
| | | this.total = total;
|
| | | }
|
| | |
|
| | | public List<?> getRows()
|
| | | {
|
| | | return rows;
|
| | | }
|
| | |
|
| | | public void setRows(List<?> rows)
|
| | | {
|
| | | this.rows = rows;
|
| | | }
|
| | |
|
| | | public int getCode()
|
| | | {
|
| | | return code;
|
| | | }
|
| | |
|
| | | public void setCode(int code)
|
| | | {
|
| | | this.code = code;
|
| | | }
|
| | |
|
| | | public String getMsg()
|
| | | {
|
| | | return msg;
|
| | | }
|
| | |
|
| | | public void setMsg(String msg)
|
| | | {
|
| | | this.msg = msg;
|
| | | }
|
| | | }
|
| | | package com.ruoyi.common.core.page; |
| | | |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 表格分页数据对象 |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | |
| | | @Data |
| | | @NoArgsConstructor |
| | | @Schema(name = "分页响应对象") |
| | | public class TableDataInfo<T> implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 总记录数 |
| | | */ |
| | | @Schema(name = "总记录数") |
| | | private long total; |
| | | |
| | | /** |
| | | * 列表数据 |
| | | */ |
| | | @Schema(name = "列表数据") |
| | | private List<T> rows; |
| | | |
| | | /** |
| | | * 消息状态码 |
| | | */ |
| | | @Schema(name = "消息状态码") |
| | | private int code; |
| | | |
| | | /** |
| | | * 消息内容 |
| | | */ |
| | | @Schema(name = "消息内容") |
| | | private String msg; |
| | | |
| | | /** |
| | | * 分页 |
| | | * |
| | | * @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; |
| | | } |
| | | |
| | | } |