package com.ruoyi.common.config.datasource.utils;

import org.apache.ibatis.session.RowBounds;

public class PageUtil {

    public PageUtil() {
    }

    public static RowBounds getPageParam(Integer pageNum, Integer pageSize) {
        if (pageNum == null || pageNum < 1) {
            pageNum = 1;
        }

        if (pageSize == null || pageSize < 1) {
            pageSize = 10;
        }

        return new RowBounds((pageNum - 1) * pageSize, pageSize);
    }

    public static int getPageNum(Integer pageNum) {
        if (pageNum == null || pageNum < 1) {
            pageNum = 0;
        }

        return pageNum;
    }

    public static int getPageSize(Integer pageSize) {
        if (pageSize == null || pageSize < 1) {
            pageSize = 10;
        }

        return pageSize;
    }

}
