mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Query.of(entity)构建时传入fields
This commit is contained in:
parent
e91d5d8e44
commit
f424fc09c4
@ -14,6 +14,7 @@
|
|||||||
* 【core 】 身份证工具类isValidCard18、isValidCard15入参null直接返回null(pr#1034@Gitee)
|
* 【core 】 身份证工具类isValidCard18、isValidCard15入参null直接返回null(pr#1034@Gitee)
|
||||||
* 【http 】 使用multiparty方式支持body参数(issue#3158@Github)
|
* 【http 】 使用multiparty方式支持body参数(issue#3158@Github)
|
||||||
* 【core 】 ZipReader增加setMaxSizeDiff方法,自定义或关闭ZipBomb(issue#3018@Github)
|
* 【core 】 ZipReader增加setMaxSizeDiff方法,自定义或关闭ZipBomb(issue#3018@Github)
|
||||||
|
* 【db 】 Query.of(entity)构建时传入fields(issue#I7M5JU@Gitee)
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 修复MapUtil工具使用filter方法构造传入参数结果问题(issue#3162@Github)
|
* 【core 】 修复MapUtil工具使用filter方法构造传入参数结果问题(issue#3162@Github)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.hutool.db.sql;
|
package cn.hutool.db.sql;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.db.DbRuntimeException;
|
import cn.hutool.db.DbRuntimeException;
|
||||||
@ -7,6 +8,7 @@ import cn.hutool.db.Entity;
|
|||||||
import cn.hutool.db.Page;
|
import cn.hutool.db.Page;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询对象,用于传递查询所需的字段值<br>
|
* 查询对象,用于传递查询所需的字段值<br>
|
||||||
@ -34,7 +36,13 @@ public class Query {
|
|||||||
* @since 5.5.3
|
* @since 5.5.3
|
||||||
*/
|
*/
|
||||||
public static Query of(Entity where){
|
public static Query of(Entity where){
|
||||||
return new Query(SqlUtil.buildConditions(where), where.getTableName());
|
final Query query = new Query(SqlUtil.buildConditions(where), where.getTableName());
|
||||||
|
final Set<String> fieldNames = where.getFieldNames();
|
||||||
|
if(CollUtil.isNotEmpty(fieldNames)){
|
||||||
|
query.setFields(fieldNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------- Constructor start
|
// --------------------------------------------------------------- Constructor start
|
||||||
|
@ -14,6 +14,10 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class JfireELEngine implements ExpressionEngine {
|
public class JfireELEngine implements ExpressionEngine {
|
||||||
|
|
||||||
|
static {
|
||||||
|
checkEngineExist(Expression.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造
|
* 构造
|
||||||
*/
|
*/
|
||||||
@ -24,4 +28,8 @@ public class JfireELEngine implements ExpressionEngine {
|
|||||||
public Object eval(String expression, Map<String, Object> context) {
|
public Object eval(String expression, Map<String, Object> context) {
|
||||||
return Expression.parse(expression).calculate(context);
|
return Expression.parse(expression).calculate(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkEngineExist(Class<?> clazz){
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,10 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class RhinoEngine implements ExpressionEngine {
|
public class RhinoEngine implements ExpressionEngine {
|
||||||
|
|
||||||
|
static {
|
||||||
|
checkEngineExist(Context.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object eval(String expression, Map<String, Object> context) {
|
public Object eval(String expression, Map<String, Object> context) {
|
||||||
final Context ctx = Context.enter();
|
final Context ctx = Context.enter();
|
||||||
@ -31,4 +35,8 @@ public class RhinoEngine implements ExpressionEngine {
|
|||||||
Context.exit();
|
Context.exit();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkEngineExist(Class<?> clazz){
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user