top.doudou.common.tool.dto.PageModel Maven / Gradle / Ivy
package top.doudou.common.tool.dto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import org.springframework.data.domain.Page;
import top.doudou.common.tool.utils.ListUtils;
import java.io.Serializable;
import java.util.List;
/**
* @author 傻男人<[email protected]>
* @create 2018-09-30-10:56
*/
@ApiModel("简单分页模型")
public class PageModel implements Serializable {
public PageModel(Long count, List results) {
this.count = count;
this.results = results;
}
@SuppressWarnings("unchecked")
public PageModel(Page page) {
this.count = page.getTotalElements();
this.results = page.getContent();
}
public PageModel(Page page, Class target) {
this.count = page.getTotalElements();
this.results = ListUtils.copyList(page.getContent(), target);
}
public PageModel(IPage page,Class target){
this.results = ListUtils.copyList(page.getRecords(), target);
this.count = page.getTotal();
}
private long count;
private List results;
public long getCount() {
return count;
}
public void setCount(long count) {
this.count = count;
}
public List getResults() {
return results;
}
public void setResults(List results) {
this.results = results;
}
}