blob: 5d36845b5df65b9337521d9bec4a79463b276173 (
plain)
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
|
package com.mesasoft.cn.dao.sqlprovider;
import com.mesasoft.cn.SketchApplication;
import com.mesasoft.cn.modules.constant.ConfigConsts;
import com.mesasoft.cn.modules.constant.DefaultValues;
import com.zhazhapan.util.Checker;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;
/**
* @author pantao
* @since 2018/1/19
*/
public class UserSqlProvider {
public String updateAuthById() {
return CommonSqlProvider.updateAuthById("user");
}
public String getUserBy(@Param("permission") int permission, @Param("condition") String condition, @Param
("offset") int offset) {
String sql = new SQL() {{
SELECT("*");
FROM("user");
if (permission == DefaultValues.THREE_INT) {
WHERE("permission<3");
} else if (permission == DefaultValues.TWO_INT) {
WHERE("permission<2");
} else {
WHERE("permission<0");
}
if (Checker.isNotEmpty(condition)) {
WHERE("username like '%" + condition + "%' or email like '%" + condition + "%' or real_name like '" +
condition + "'");
}
ORDER_BY(SketchApplication.settings.getStringUseEval(ConfigConsts.USER_ORDER_BY_OF_SETTINGS));
}}.toString();
int size = SketchApplication.settings.getIntegerUseEval(ConfigConsts.USER_PAGE_SIZE_OF_SETTINGS);
return sql + " limit " + (offset * size) + "," + size;
}
}
|