Commit 8e0dcf55 authored by yanzg's avatar yanzg

默认日期格式的支持

parent e4c2462e
...@@ -13,31 +13,34 @@ import java.util.Map; ...@@ -13,31 +13,34 @@ import java.util.Map;
* @author 颜佐光 * @author 颜佐光
*/ */
class SqlCondUtil { class SqlCondUtil {
/**
* 代码片段等级
*/
public static final int COND_CODE = 0;
/** /**
* 时间等级 * 时间等级
*/ */
public static final int COND_DATE = 0; public static final int COND_DATE = 1;
/** /**
* ID等级 * ID等级
*/ */
public static final int COND_ID = 1; public static final int COND_ID = 2;
/** /**
* 普通相等 * 普通相等
*/ */
public static final int COND_COMMON = 2; public static final int COND_COMMON = 3;
/** /**
* 普通IN,NOT IN * 普通IN,NOT IN
*/ */
public static final int COND_IN = 3; public static final int COND_IN = 4;
/** /**
* Like条件 * Like条件
*/ */
public static final int COND_LIKE = 4; public static final int COND_LIKE = 5;
/** /**
* 全文索引 * 全文索引
*/ */
public static final int COND_MATCH = 5; public static final int COND_MATCH = 6;
/** /**
* 将SQL语句条件排序,符合索引 * 将SQL语句条件排序,符合索引
...@@ -73,19 +76,25 @@ class SqlCondUtil { ...@@ -73,19 +76,25 @@ class SqlCondUtil {
return COND_COMMON; return COND_COMMON;
} }
SqlCond<?> cond = field.getCond(); SqlCond<?> cond = field.getCond();
for (String fieldName : cond.getFields()) { boolean isWhere = false;
fieldName = fieldName.toLowerCase();
if (fieldName.indexOf("date") > -1 || fieldName.indexOf("time") > -1) {
return COND_DATE;
} else if (fieldName.indexOf("id") > -1) {
return COND_ID;
}
}
int len = field.getCodes().size() / 2; int len = field.getCodes().size() / 2;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
String codeName = field.getCodes().get(i * 2); String codeName = field.getCodes().get(i * 2).toLowerCase();
String codeValue = field.getCodes().get(i * 2 + 1).toLowerCase(); String codeValue = field.getCodes().get(i * 2 + 1).toLowerCase();
if (codeName.indexOf("where") < 0) {
continue;
}
isWhere = true;
for (String fieldName : cond.getFields()) {
fieldName = fieldName.toLowerCase();
if (fieldName.indexOf("date") > -1 || fieldName.indexOf("time") > -1) {
return COND_DATE;
} else if (fieldName.indexOf("id") > -1) {
return COND_ID;
}
}
if (codeValue.indexOf("in") > -1) { if (codeValue.indexOf("in") > -1) {
return COND_IN; return COND_IN;
} else if (codeValue.indexOf("like") > -1) { } else if (codeValue.indexOf("like") > -1) {
...@@ -95,6 +104,11 @@ class SqlCondUtil { ...@@ -95,6 +104,11 @@ class SqlCondUtil {
} }
} }
return COND_COMMON; if (isWhere) {
return COND_COMMON;
} else {
return COND_CODE;
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment