package com.lesingle.edu.common.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * Page Utilities
 */
public class PageUtils {

    private PageUtils() {
    }

    public static <T> Page<T> of(Integer pageNum, Integer pageSize) {
        int num = pageNum == null || pageNum < 1 ? 1 : pageNum;
        int size = pageSize == null || pageSize < 1 ? 10 : pageSize;
        return new Page<>(num, size);
    }

    public static <T> Page<T> of(Integer pageNum, Integer pageSize, Integer defaultSize) {
        int num = pageNum == null || pageNum < 1 ? 1 : pageNum;
        int size = pageSize == null || pageSize < 1 ? defaultSize : pageSize;
        return new Page<>(num, size);
    }

}
