package com.fjhx.base;

import java.util.Map;

/**
 * @Author:caozj
 * @DATE:2022/7/12 17:35
 */
public class ListPageMap {


    private static final String page_num_key = "pageNum";
    private static final String page_size_key = "pageSize";

    private static final String pager_key = "pager";
    private static final String start_key = "start";
    private static final String end_key = "end";

    public static final int pageNum_def = 1;
    public static final int pageSize_def = 10;

    /**
     * 获取分页列表请求参数
     *
     * @param condition 查询条件
     * @return
     */
    public static void getListPageMap(Map<String, Object> condition) {
        // 起始页
        int pageNum = (condition.get(page_num_key) == null || condition.get(page_num_key) == "") ? pageNum_def : Integer.valueOf(String.valueOf(condition.get(page_num_key)));
        // 每页显示数
        int pageSize = (condition.get(page_size_key) == null || condition.get(page_size_key) == "") ? pageSize_def : Integer.valueOf(String.valueOf(condition.get(page_size_key)));

        Pager pager = new Pager(pageNum, pageSize);
        condition.put(pager_key, pager);
        condition.put(start_key, pager.getPageStart());
        condition.put(end_key, pager.getPageSize());
    }
}
