提交 | 用户 | 时间
|
1ac2bc
|
1 |
/** |
懒 |
2 |
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) |
|
3 |
* <p> |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* <p> |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* <p> |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package cn.stylefeng.guns.base.pojo.page; |
|
17 |
|
|
18 |
import cn.stylefeng.roses.core.util.HttpContext; |
|
19 |
import cn.stylefeng.roses.core.util.ToolUtil; |
|
20 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
21 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
22 |
|
|
23 |
import javax.servlet.http.HttpServletRequest; |
|
24 |
|
|
25 |
/** |
|
26 |
* Layui Table默认的分页参数创建 |
|
27 |
* |
|
28 |
* @author fengshuonan |
|
29 |
* @date 2017-04-05 22:25 |
|
30 |
*/ |
|
31 |
public class LayuiPageFactory { |
|
32 |
|
|
33 |
/** |
|
34 |
* 获取layui table的分页参数 |
|
35 |
* |
|
36 |
* @author fengshuonan |
|
37 |
* @Date 2019/1/25 22:13 |
|
38 |
*/ |
|
39 |
public static Page defaultPage() { |
|
40 |
HttpServletRequest request = HttpContext.getRequest(); |
|
41 |
|
|
42 |
int limit = 20; |
|
43 |
int page = 1; |
|
44 |
|
|
45 |
//每页多少条数据 |
|
46 |
String limitString = request.getParameter("limit"); |
|
47 |
if (ToolUtil.isNotEmpty(limitString)) { |
|
48 |
limit = Integer.parseInt(limitString); |
|
49 |
} |
|
50 |
|
|
51 |
//第几页 |
|
52 |
String pageString = request.getParameter("page"); |
|
53 |
if (ToolUtil.isNotEmpty(pageString)) { |
|
54 |
page = Integer.parseInt(pageString); |
|
55 |
} |
|
56 |
|
|
57 |
return new Page(page, limit); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* 创建layui能识别的分页响应参数 |
|
62 |
* |
|
63 |
* @author fengshuonan |
|
64 |
* @Date 2019/1/25 22:14 |
|
65 |
*/ |
|
66 |
public static LayuiPageInfo createPageInfo(IPage page) { |
|
67 |
LayuiPageInfo result = new LayuiPageInfo(); |
|
68 |
result.setCount(page.getTotal()); |
|
69 |
result.setData(page.getRecords()); |
|
70 |
return result; |
|
71 |
} |
|
72 |
} |