package com.starry.admin.common;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;


public class PageBuilder {
    public static final String PAGE_NUM = "pageNum";

    public static final String PAGE_SIZE = "pageSize";

    public static <T> Page<T> build() {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        Integer pageNum = Integer.valueOf(attributes.getRequest().getParameter(PAGE_NUM));
        Integer pageSize = Integer.valueOf(attributes.getRequest().getParameter(PAGE_SIZE));
        return new Page<>(pageNum, pageSize);
    }

}
