package com.usky.vpp.util;

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

import java.util.Map;

/**
 * 分页参数解析
 */
public final class VppPageHelper {

    private VppPageHelper() {
    }

    public static <T> Page<T> of(Map<String, Object> params) {
        long current = 1;
        long size = 10;
        if (params != null) {
            if (params.get("current") != null) {
                current = Long.parseLong(params.get("current").toString());
            }
            if (params.get("size") != null) {
                size = Long.parseLong(params.get("size").toString());
            }
        }
        if (size > 100) {
            size = 100;
        }
        return new Page<>(current, size);
    }
}
