package com.sinata.core.util;
|
|
import com.baomidou.mybatisplus.plugins.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);
|
}
|
}
|