mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
QueryCondition.when(Predicate<T>)。若logic为like时去除前后的%,再传入fn
This commit is contained in:
parent
8d4a68f558
commit
461843d1b3
@ -118,7 +118,18 @@ public class QueryCondition implements Serializable {
|
|||||||
this.effective = fn.get();
|
this.effective = fn.get();
|
||||||
}
|
}
|
||||||
public <T> QueryCondition when(Predicate<T> fn){
|
public <T> QueryCondition when(Predicate<T> fn){
|
||||||
this.effective = fn.test((T) value);
|
Object val = this.value;
|
||||||
|
if (LOGIC_LIKE.equals(logic)) {
|
||||||
|
String valStr = (String) val;
|
||||||
|
if (valStr.startsWith("%")) {
|
||||||
|
valStr = valStr.substring(1);
|
||||||
|
}
|
||||||
|
if (valStr.endsWith("%")) {
|
||||||
|
valStr = valStr.substring(0, valStr.length() - 1);
|
||||||
|
}
|
||||||
|
val = valStr;
|
||||||
|
}
|
||||||
|
this.effective = fn.test((T) val);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user