Skip to content

Commit

Permalink
refactor: 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed May 28, 2024
1 parent 52c1d05 commit 834426f
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import org.hswebframework.ezorm.core.param.Term;
import org.hswebframework.ezorm.rdb.metadata.RDBColumnMetadata;
import org.hswebframework.ezorm.rdb.operator.builder.fragments.PrepareSqlFragments;
import org.hswebframework.ezorm.rdb.operator.builder.fragments.SimpleSqlFragments;
import org.hswebframework.ezorm.rdb.operator.builder.fragments.SqlFragments;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class BetweenAndTermFragmentBuilder extends AbstractTermFragmentBuilder {
Expand All @@ -19,25 +21,24 @@ public BetweenAndTermFragmentBuilder(String termType, String name, boolean isNot

@Override
public SqlFragments createFragments(String columnFullName, RDBColumnMetadata column, Term term) {
PrepareSqlFragments fragments = PrepareSqlFragments.of();

List<Object> val = convertList(column, term);

List<Object> values = new ArrayList<>(2);
if (val.isEmpty()) {
values.add(null);
values.add(null);
} else if (val.size() == 1) {
values.add(val.get(0));
values.add(val.get(0));
} else {
values.add(val.get(0));
values.add(val.get(1));
if (val.size() != 2) {
List<Object> values = new ArrayList<>(2);
if (val.isEmpty()) {
values.add(null);
values.add(null);
} else if (val.size() == 1) {
values.add(val.get(0));
values.add(val.get(0));
} else {
values.add(val.get(0));
values.add(val.get(1));
}
val = values;
}

return fragments
.addSql(columnFullName)
.addSql(symbol)
.addParameter(values);
return SimpleSqlFragments
.of(Arrays.asList(columnFullName, symbol), val);
}
}

0 comments on commit 834426f

Please sign in to comment.