puzhibing
2023-10-08 22199bbdda579861736420fe26c2873ab0f5d21c
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
package com.sinata.rest.core.util;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
import java.util.List;
 
/**
 * sql语句工具类
 *
 * @author fengshuonan
 * @date 2016年12月6日 下午1:01:54
 */
public class SqlUtil {
 
    /**
     * @Description 根据集合的大小,输出相应个数"?"
     * @author fengshuonan
     */
    public static String parse(List<?> list) {
        String str = "";
        if (list != null && list.size() > 0) {
            str = str + "?";
            for (int i = 1; i < list.size(); i++) {
                str = str + ",?";
            }
        }
        return str;
    }
 
    /**
     * 前后拼接单引号
     *
     * @param value 参数值
     * @return
     */
    public static String addSingleQuotes(Object value) {
        if (null == value) {
            return "''";
        }
        return "'" + value + "'";
    }
 
    /**
     * 设置默认分页
     *
     * @param current 当前页
     * @param size    分页条数
     * @return
     */
    public static Page setPage(Integer current, Integer size) {
        return new Page<>(current == null ? 1 : current, size == null ? 20 : size);
    }
}