All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.doudou.common.tool.dto.PageModel Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy