com.redismq.server.pojo.PageResult Maven / Gradle / Ivy
package com.redismq.server.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import static java.util.stream.Collectors.toList;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResult {
private int code;
private String message;
private Boolean success;
private List list = Collections.emptyList();
private long total = 0;
private long page = 1;
private long size = 10;
public PageResult(int code, String message, Boolean success) {
this.code = code;
this.message = message;
this.success = success;
}
public PageResult(long page,long size) {
PageResult pageResult = new PageResult(200, "操作成功", true);
pageResult.setPage(page);
pageResult.setSize(size);
}
//定义分页的消息
public static PageResult success(long total,List list) {
PageResult pageResult = new PageResult(200, "操作成功", true);
pageResult.setList(list);
pageResult.setTotal(total);
return pageResult;
}
@SuppressWarnings("unchecked")
public PageResult convert(Function super T, ? extends R> mapper) {
List collect = this.getList().stream().map(mapper).collect(toList());
PageResult result = (PageResult) this;
result.setList(collect);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy