兼容多括号

This commit is contained in:
2026-06-12 11:36:10 +08:00
parent b764cb1cb5
commit a6e3980c18
2 changed files with 10 additions and 13 deletions

View File

@@ -499,9 +499,6 @@ public class FormTableExecutor {
int count = 0;
for (FormUpdateField f : fields) {
if (f.getValue() == null || "".equals(f.getValue()) || "null".equals(f.getValue())) {
continue;
}
if (count++ > 0) {
sql.append(", ");
}
@@ -587,7 +584,7 @@ public class FormTableExecutor {
for (int i = 0; i < conditions.size(); i++) {
FormWhereCondition c = conditions.get(i);
// 左括号
if (c.isStartWithBracket()) {
for (int b = 0; b < c.getStartWithBracket(); b++) {
whereCause.append("(");
}
String field = c.getFieldName();
@@ -634,7 +631,7 @@ public class FormTableExecutor {
}
}
// 右括号
if (c.isEndWithBracket()) {
for (int b = 0; b < c.getEndWithBracket(); b++) {
whereCause.append(")");
}
// AND / OR

View File

@@ -10,8 +10,8 @@ public class FormWhereCondition {
private List<Object> values; //值
private ClauseFactor clauseFactor = ClauseFactor.EQ; //条件因子 eq lt gt not_null null
private ClauseFactor concatFactor = ClauseFactor.AND; //拼接因子
private boolean startWithBracket = false; //是否以括号开头生成子条件
private boolean endWithBracket = false; //是否以括号结尾结束子条件
private int startWithBracket = 0; //条件前加几个左括号
private int endWithBracket = 0; //条件后加几个右括号
private String index;
private String expression; //自定义SQL表达式 如 ROUND(CAST(fieldName AS DECIMAL(10,2)), 2) > ?
private String fieldExpression; //字段表达式 如 CAST(fieldName AS DECIMAL(10,2))fieldName会被替换为实际字段名
@@ -55,12 +55,12 @@ public class FormWhereCondition {
return this;
}
public FormWhereCondition startWithBracket(boolean startWithBracket) {
public FormWhereCondition startWithBracket(int startWithBracket) {
this.startWithBracket = startWithBracket;
return this;
}
public FormWhereCondition endWithBracket(boolean endWithBracket) {
public FormWhereCondition endWithBracket(int endWithBracket) {
this.endWithBracket = endWithBracket;
return this;
}
@@ -91,11 +91,11 @@ public class FormWhereCondition {
this.clauseFactor = clauseFactor;
}
public boolean isStartWithBracket() {
public int getStartWithBracket() {
return startWithBracket;
}
public void setStartWithBracket(boolean startWithBracket) {
public void setStartWithBracket(int startWithBracket) {
this.startWithBracket = startWithBracket;
}
@@ -139,11 +139,11 @@ public class FormWhereCondition {
this.index = index;
}
public boolean isEndWithBracket() {
public int getEndWithBracket() {
return endWithBracket;
}
public void setEndWithBracket(boolean endWithBracket) {
public void setEndWithBracket(int endWithBracket) {
this.endWithBracket = endWithBracket;
}