多易 亿级在线实时动态规则运营系统(v1架构)
/**
* query 模糊查询
*
* @param field 字段
* @param value 模糊匹配目标值
* @param regex 添加自定义匹配规则
* @return
*/
public static Criteria queryLike(String field, Object value, String regex) {
Pattern compile = null;
if (StringUtils.isNotBlank(regex)) {
compile = Pattern.compile(regex);
} else {
compile = Pattern.compile("^.*" + value + ".*$", Pattern.CASE_INSENSITIVE);
}
return Criteria.where(field).regex(compile);
}