兼容多括号
This commit is contained in:
@@ -499,9 +499,6 @@ public class FormTableExecutor {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (FormUpdateField f : fields) {
|
for (FormUpdateField f : fields) {
|
||||||
if (f.getValue() == null || "".equals(f.getValue()) || "null".equals(f.getValue())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (count++ > 0) {
|
if (count++ > 0) {
|
||||||
sql.append(", ");
|
sql.append(", ");
|
||||||
}
|
}
|
||||||
@@ -587,7 +584,7 @@ public class FormTableExecutor {
|
|||||||
for (int i = 0; i < conditions.size(); i++) {
|
for (int i = 0; i < conditions.size(); i++) {
|
||||||
FormWhereCondition c = conditions.get(i);
|
FormWhereCondition c = conditions.get(i);
|
||||||
// 左括号
|
// 左括号
|
||||||
if (c.isStartWithBracket()) {
|
for (int b = 0; b < c.getStartWithBracket(); b++) {
|
||||||
whereCause.append("(");
|
whereCause.append("(");
|
||||||
}
|
}
|
||||||
String field = c.getFieldName();
|
String field = c.getFieldName();
|
||||||
@@ -634,7 +631,7 @@ public class FormTableExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 右括号
|
// 右括号
|
||||||
if (c.isEndWithBracket()) {
|
for (int b = 0; b < c.getEndWithBracket(); b++) {
|
||||||
whereCause.append(")");
|
whereCause.append(")");
|
||||||
}
|
}
|
||||||
// AND / OR
|
// AND / OR
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ public class FormWhereCondition {
|
|||||||
private List<Object> values; //值
|
private List<Object> values; //值
|
||||||
private ClauseFactor clauseFactor = ClauseFactor.EQ; //条件因子 eq lt gt not_null null
|
private ClauseFactor clauseFactor = ClauseFactor.EQ; //条件因子 eq lt gt not_null null
|
||||||
private ClauseFactor concatFactor = ClauseFactor.AND; //拼接因子
|
private ClauseFactor concatFactor = ClauseFactor.AND; //拼接因子
|
||||||
private boolean startWithBracket = false; //是否以括号开头生成子条件
|
private int startWithBracket = 0; //条件前加几个左括号
|
||||||
private boolean endWithBracket = false; //是否以括号结尾结束子条件
|
private int endWithBracket = 0; //条件后加几个右括号
|
||||||
private String index;
|
private String index;
|
||||||
private String expression; //自定义SQL表达式 如 ROUND(CAST(fieldName AS DECIMAL(10,2)), 2) > ?
|
private String expression; //自定义SQL表达式 如 ROUND(CAST(fieldName AS DECIMAL(10,2)), 2) > ?
|
||||||
private String fieldExpression; //字段表达式 如 CAST(fieldName AS DECIMAL(10,2)),fieldName会被替换为实际字段名
|
private String fieldExpression; //字段表达式 如 CAST(fieldName AS DECIMAL(10,2)),fieldName会被替换为实际字段名
|
||||||
@@ -55,12 +55,12 @@ public class FormWhereCondition {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormWhereCondition startWithBracket(boolean startWithBracket) {
|
public FormWhereCondition startWithBracket(int startWithBracket) {
|
||||||
this.startWithBracket = startWithBracket;
|
this.startWithBracket = startWithBracket;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormWhereCondition endWithBracket(boolean endWithBracket) {
|
public FormWhereCondition endWithBracket(int endWithBracket) {
|
||||||
this.endWithBracket = endWithBracket;
|
this.endWithBracket = endWithBracket;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -91,11 +91,11 @@ public class FormWhereCondition {
|
|||||||
this.clauseFactor = clauseFactor;
|
this.clauseFactor = clauseFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStartWithBracket() {
|
public int getStartWithBracket() {
|
||||||
return startWithBracket;
|
return startWithBracket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartWithBracket(boolean startWithBracket) {
|
public void setStartWithBracket(int startWithBracket) {
|
||||||
this.startWithBracket = startWithBracket;
|
this.startWithBracket = startWithBracket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,11 +139,11 @@ public class FormWhereCondition {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEndWithBracket() {
|
public int getEndWithBracket() {
|
||||||
return endWithBracket;
|
return endWithBracket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndWithBracket(boolean endWithBracket) {
|
public void setEndWithBracket(int endWithBracket) {
|
||||||
this.endWithBracket = endWithBracket;
|
this.endWithBracket = endWithBracket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user