Skip to content

Commit

Permalink
fix: 优化通用查询注解解析器
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Mar 31, 2023
1 parent 9f25925 commit a623acd
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ private static <R> void parse(Query queryAnnotation, String fieldName, Object fi
String property = queryAnnotation.property();
fieldName = StrUtil.blankToDefault(property, fieldName);
String columnName = StrUtil.toUnderlineCase(fieldName);
switch (queryAnnotation.type()) {
Query.Type queryType = queryAnnotation.type();
switch (queryType) {
case EQUAL:
queryWrapper.eq(columnName, fieldValue);
break;
Expand All @@ -163,7 +164,9 @@ private static <R> void parse(Query queryAnnotation, String fieldName, Object fi
break;
case BETWEEN:
List<Object> between = new ArrayList<>((List<Object>)fieldValue);
queryWrapper.between(columnName, between.get(0), between.get(1));
if (between.size() >= 2) {
queryWrapper.between(columnName, between.get(0), between.get(1));
}
break;
case LEFT_LIKE:
queryWrapper.likeLeft(columnName, fieldValue);
Expand Down Expand Up @@ -191,7 +194,7 @@ private static <R> void parse(Query queryAnnotation, String fieldName, Object fi
queryWrapper.isNotNull(columnName);
break;
default:
break;
throw new IllegalArgumentException(String.format("暂不支持 [%s] 查询类型", queryType));
}
}
}

0 comments on commit a623acd

Please sign in to comment.