package cn.stylefeng.guns.zjxlUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.*;

/***
 * @ClassName: PageUtil
 * @Description:
 * @Auther: shi kejing
 * @Date: 2020/11/5 13:55
 */
public class PageUtil {

    public static Map<String ,Object> getPage(List object, int pageNo, int pageSize, Integer allCount) {
        Map<String,Object> map = new HashMap<>();
        Integer totalPage = 0;
        Integer totalRows = allCount;
        if (totalRows>0){
            map.put("pageNo",pageNo);
            map.put("pageSize",pageSize);
            if(totalRows%pageSize==0){
                totalPage=totalRows/pageSize;
            }else{
                totalPage=totalRows/pageSize+1;
            }
            map.put("totalPage",totalPage);//所有的数据一共多少页
            map.put("totalRows",totalRows);//所有数据的条数
            map.put("rows",object);
            List list = new ArrayList();
            for (int i=1; i <= totalPage; i++){
                list.add(i);
            }
            map.put("rainbow",list);
        }
        return map;
    }

}
