refactor(data): MyBatis Plus QueryTypeEnum => QueryType,并取消实现 IBaseEnum 接口

This commit is contained in:
2023-12-13 23:24:17 +08:00
parent 7997267060
commit bc00c9bab0
3 changed files with 5 additions and 5 deletions

View File

@@ -16,7 +16,7 @@
package top.charles7c.continew.starter.data.mybatis.plus.annotation; package top.charles7c.continew.starter.data.mybatis.plus.annotation;
import top.charles7c.continew.starter.data.mybatis.plus.enums.QueryTypeEnum; import top.charles7c.continew.starter.data.mybatis.plus.enums.QueryType;
import java.lang.annotation.*; import java.lang.annotation.*;
@@ -40,7 +40,7 @@ public @interface Query {
/** /**
* 查询类型(等值查询、模糊查询、范围查询等) * 查询类型(等值查询、模糊查询、范围查询等)
*/ */
QueryTypeEnum type() default QueryTypeEnum.EQUAL; QueryType type() default QueryType.EQUAL;
/** /**
* 多属性模糊查询,仅支持 String 类型属性 * 多属性模糊查询,仅支持 String 类型属性

View File

@@ -27,7 +27,7 @@ import lombok.RequiredArgsConstructor;
*/ */
@Getter @Getter
@RequiredArgsConstructor @RequiredArgsConstructor
public enum QueryTypeEnum implements IBaseEnum<Integer> { public enum QueryType {
/** /**
* 等值查询例如WHERE `age` = 18 * 等值查询例如WHERE `age` = 18

View File

@@ -27,7 +27,7 @@ import top.charles7c.continew.starter.core.exception.BadRequestException;
import top.charles7c.continew.starter.core.util.ReflectUtils; import top.charles7c.continew.starter.core.util.ReflectUtils;
import top.charles7c.continew.starter.core.util.validate.ValidationUtils; import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
import top.charles7c.continew.starter.data.mybatis.plus.annotation.Query; import top.charles7c.continew.starter.data.mybatis.plus.annotation.Query;
import top.charles7c.continew.starter.data.mybatis.plus.enums.QueryTypeEnum; import top.charles7c.continew.starter.data.mybatis.plus.enums.QueryType;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
@@ -130,7 +130,7 @@ public class QueryHelper {
// 注意:数据库规范中列采用下划线连接法命名,程序规范中变量采用驼峰法命名 // 注意:数据库规范中列采用下划线连接法命名,程序规范中变量采用驼峰法命名
String property = queryAnnotation.property(); String property = queryAnnotation.property();
String columnName = StrUtil.toUnderlineCase(StrUtil.blankToDefault(property, fieldName)); String columnName = StrUtil.toUnderlineCase(StrUtil.blankToDefault(property, fieldName));
QueryTypeEnum queryType = queryAnnotation.type(); QueryType queryType = queryAnnotation.type();
switch (queryType) { switch (queryType) {
case EQUAL -> queryWrapper.eq(columnName, fieldValue); case EQUAL -> queryWrapper.eq(columnName, fieldValue);
case NOT_EQUAL -> queryWrapper.ne(columnName, fieldValue); case NOT_EQUAL -> queryWrapper.ne(columnName, fieldValue);