@@ -26,11 +26,29 @@ public QueryBuilder select(String select) {
2626 public class Condition {
2727 private List <ConditionParameter > conditions = new ArrayList <>();
2828
29+ public Splice notNullCondition (String conditionSql ,String paramKey , Object paramVal ) {
30+ if (paramVal !=null ) {
31+ conditions .add (new ConditionParameter (paramKey , paramVal , conditionSql ));
32+ }else {
33+ conditions .add (new ConditionParameter ("1=1" ));
34+ }
35+ return splice ;
36+ }
37+
2938 public Splice condition (String conditionSql ,String paramKey , Object paramVal ) {
3039 conditions .add (new ConditionParameter (paramKey , paramVal , conditionSql ));
3140 return splice ;
3241 }
3342
43+ public Splice notNullCondition (String conditionSql ,Map <String ,Object > map ) {
44+ if (map !=null &&map .size ()>0 ) {
45+ conditions .add (new ConditionParameter (map , conditionSql ));
46+ }else {
47+ conditions .add (new ConditionParameter ("1=1" ));
48+ }
49+ return splice ;
50+ }
51+
3452 public Splice condition (String conditionSql ,Map <String ,Object > map ) {
3553 conditions .add (new ConditionParameter (map , conditionSql ));
3654 return splice ;
@@ -41,15 +59,34 @@ public Splice condition(String conditionSql) {
4159 return splice ;
4260 }
4361
62+ public Splice notNullCondition (String conditionSql ,Object paramVal ) {
63+ if (paramVal !=null ) {
64+ conditions .add (new ConditionParameter (paramVal , conditionSql ));
65+ }else {
66+ conditions .add (new ConditionParameter ("1=1" ));
67+ }
68+ return splice ;
69+ }
70+
4471 public Splice condition (String conditionSql ,Object paramVal ) {
4572 conditions .add (new ConditionParameter ( paramVal , conditionSql ));
4673 return splice ;
4774 }
4875
76+ public Splice notNullCondition (String conditionSql ,Object ... paramVal ) {
77+ if (paramVal !=null &¶mVal .length >0 ) {
78+ conditions .add (new ConditionParameter (StringUtils .join (paramVal , "," ), conditionSql ));
79+ }else {
80+ conditions .add (new ConditionParameter ("1=1" ));
81+ }
82+ return splice ;
83+ }
84+
4985 public Splice condition (String conditionSql ,Object ... paramVal ) {
5086 conditions .add (new ConditionParameter (StringUtils .join (paramVal ,"," ), conditionSql ));
5187 return splice ;
5288 }
89+
5390 }
5491
5592 public class Splice {
0 commit comments