优化grid分页控件,增加可自定义参数而不被纳入自动生成的where语句中

This commit is contained in:
smallchill 2017-09-19 17:57:50 +08:00
parent 869f427ae2
commit 61429bec36
2 changed files with 7 additions and 8 deletions

View File

@ -121,12 +121,9 @@ public abstract class BaseGridFactory implements IGrid {
if (Func.isEmpty(map)) { if (Func.isEmpty(map)) {
map = new HashMap<>(); map = new HashMap<>();
} }
if (Func.isPostgresql()) {
//postgresql8.3+版本 字段类型敏感,如果是int型需要做强制类型转换,mysql和oracle可以无视
for (String key : map.keySet()) { for (String key : map.keySet()) {
if (key.startsWith(SqlKeyword.TOINT) || key.startsWith(SqlKeyword.IT) || key.startsWith(SqlKeyword.F_IT)) { if (key.startsWith(SqlKeyword.TOINT) || key.startsWith(SqlKeyword.IT) || key.startsWith(SqlKeyword.F_IT)) {
map.put(key, Convert.toInt(map.get(key))); map.put(key.replace(SqlKeyword.SKIP, ""), Convert.toInt(map.get(key)));
}
} }
} }
map.put(Const.ORDER_BY_STR, Func.isAllEmpty(sort, order) ? "" : (sort + " " + order)); map.put(Const.ORDER_BY_STR, Func.isAllEmpty(sort, order) ? "" : (sort + " " + order));

View File

@ -11,6 +11,7 @@ import java.util.Map;
* 定义常用的 sql关键字 * 定义常用的 sql关键字
*/ */
public class SqlKeyword { public class SqlKeyword {
public static final String SKIP = "_skip_true";
private static final String EQUAL = "_equal"; private static final String EQUAL = "_equal";
private static final String NOT_EQUAL = "_notequal"; private static final String NOT_EQUAL = "_notequal";
private static final String LIKE = "_like"; private static final String LIKE = "_like";
@ -57,6 +58,7 @@ public class SqlKeyword {
w = Func.decodeUrl(w); w = Func.decodeUrl(w);
Map<String, String> mm = JsonKit.parse(w, HashMap.class); Map<String, String> mm = JsonKit.parse(w, HashMap.class);
for (String m : mm.keySet()) { for (String m : mm.keySet()) {
if (m.endsWith(SKIP)) break;
String col = clearKeyWord(m); String col = clearKeyWord(m);
String k = ""; String k = "";
for (String key : keyWord.keySet()) { for (String key : keyWord.keySet()) {