省略号 发布于79月前 8答/2090阅
实现过程中遇到的问题:
让用 = 来查询,在前置拦截器 queryBefore中添加自定义后 ,发现sql 是
where mobile like ? and mobile = ? ,想让 直接 where mobile =?
添加的:
@Override
public void queryBefore(AopContext ac) throws Exception {
super.queryBefore(ac);
String mobile = ac.ctrl.getPara("query_mobile");
if(!xx.isEmpty(mobile)){
ac.condition = " and mobile = ?";
ac.params.add(mobile.trim());
}
}
源码解读:(专业版3.6.x)
// 数字框
if (type.equals(MetaField.TYPE_NUM)) {
// 数字框与文本框取值兼容
if (!xx.isEmpty(value))
start = value;
return numType(field, start, end, cond);
}
// 时间框
if (type.equals(MetaField.TYPE_TIME)) {
return new KeyVal(timeCondition(field), start + "," + end);
}
// 日期框
if (type.equals(MetaField.TYPE_DATE)) {
return new KeyVal(dateCondition(field), start + "," + end);
}
// 数字类型都是精确查询: mysql *int || order number||long
if (dataType.contains("int") || dataType.equals("number") || dataType.equals("long")) {
return new KeyVal(" and " + field + " = ?", value);
}
// 文本框
if (type.equals(MetaField.TYPE_TEXT) || type.equals(MetaField.TYPE_TEXTS) || type.equals(MetaField.TYPE_EDIT)) {
return new KeyVal(" and " + field + " like ?", "%" + value + "%");
}
return new KeyVal(" and " + field + " = ?", value);