parent
1a01740ed0
commit
7b6665782b
@ -0,0 +1,108 @@ |
||||
package edu.ncst.award.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; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 表格分页数据对象 |
||||
* |
||||
* @author Lion Li |
||||
*/ |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@ApiModel("分页响应对象") |
||||
public class TableDataInfo<T> implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 总记录数 |
||||
*/ |
||||
@ApiModelProperty("总记录数") |
||||
private long total; |
||||
|
||||
/** |
||||
* 单页记录数 |
||||
*/ |
||||
@ApiModelProperty("单页记录数") |
||||
private long pageSize; |
||||
|
||||
/** |
||||
* 当前页码 |
||||
*/ |
||||
@ApiModelProperty("当前页码") |
||||
private long current; |
||||
|
||||
/** |
||||
* 列表数据 |
||||
*/ |
||||
@ApiModelProperty("列表数据") |
||||
private List<T> data; |
||||
|
||||
|
||||
/** |
||||
* 消息状态码 |
||||
*/ |
||||
@ApiModelProperty("消息状态码") |
||||
private int code; |
||||
|
||||
/** |
||||
* 消息内容 |
||||
*/ |
||||
@ApiModelProperty("消息内容") |
||||
private String msg; |
||||
|
||||
/** |
||||
* 为了适配antd pro |
||||
*/ |
||||
@ApiModelProperty("success") |
||||
private Boolean success; |
||||
|
||||
|
||||
/** |
||||
* 分页 |
||||
* |
||||
* @param list 列表数据 |
||||
* @param total 总记录数 |
||||
*/ |
||||
public TableDataInfo(List<T> list, long total) { |
||||
this.data = 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.setData(page.getRecords()); |
||||
rspData.setTotal(page.getTotal()); |
||||
rspData.setSuccess(true); |
||||
rspData.setCurrent(page.getCurrent()); |
||||
rspData.setPageSize(page.getSize()); |
||||
return rspData; |
||||
} |
||||
|
||||
public static <T> TableDataInfo<T> build(List<T> list) { |
||||
TableDataInfo<T> rspData = new TableDataInfo<>(); |
||||
rspData.setCode(HttpStatus.HTTP_OK); |
||||
rspData.setMsg("查询成功"); |
||||
rspData.setData(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; |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue