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

com.shixinke.utils.web.common.SearchDTO Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package com.shixinke.utils.web.common;

/**
 * @author shixinke
 * @version 1.0
 * created 19-2-22 下午4:38
 */
public class SearchDTO implements RequestDTO {
    private Integer page;
    private Integer pageSize;
    private Integer offset;

    public Integer getPage() {
        return checkNum(page);
    }

    public void setPage(Integer page) {
        this.page = checkNum(page);
    }

    public Integer getPageSize() {
        return checkNum(pageSize);
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = checkNum(pageSize);
    }

    public Integer getOffset() {
        if (offset == null || offset < 0) {
            return (page - 1) * pageSize;
        }
        return offset;
    }

    public void setOffset(Integer offset) {
        if (offset == null || offset < 0) {
            offset = 0;
        }
        this.offset = offset;
    }

    private Integer checkNum(Integer num) {
        if (num == null || num < 1) {
            return 1;
        }
        return num;
    }

    @Override
    public String toString() {
        return "SearchDTO{" +
                "page=" + page +
                ", pageSize=" + pageSize +
                ", offset=" + offset +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy