cloudroam
2025-03-10 c306cba52bcc3e2c423f77d4a52c35ad04c52038
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.jsh.erp.utils;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
 
/**
 * @author jishenghua qq752718920  2018-10-7 15:26:27
 */
public class ParamUtils {
    public static String getPageOffset(Integer currentPage, Integer pageSize) {
        if (currentPage != null && pageSize != null) {
            int offset = (currentPage - 1) * pageSize;
            if (offset <= 0) {
                return "0";
            } else {
                return new StringBuffer().append(offset).toString();
            }
        }
        return null;
    }
    public static Integer getNumberPageOffset(Integer currentPage, Integer pageSize) {
        if (currentPage != null && pageSize != null) {
            int offset = (currentPage - 1) * pageSize;
            if (offset <= 0) {
                return 0;
            } else {
                return offset;
            }
        }
        return null;
    }
    public static Integer getNumberPageRows(Integer currentPage, Integer pageSize) {
        if (currentPage != null && pageSize != null) {
            int rows = (currentPage) * pageSize;
            if (rows <= 0) {
                return 0;
            } else {
                return rows;
            }
        }
        return null;
    }
 
    public static HashMap<String, String> requestToMap(HttpServletRequest request) {
 
        HashMap<String, String> parameterMap = new HashMap<String, String>();
        Enumeration<String> names = request.getParameterNames();
        if (names != null) {
            for (String name : Collections.list(names)) {
                parameterMap.put(name, request.getParameter(name));
            }
        }
        return parameterMap;
    }
}