refactor: 优化 QueryTypeEnum 枚举值命名

This commit is contained in:
Charles7c 2024-01-23 23:46:34 +08:00
parent 2df4cceedd
commit 9648cf64a4
12 changed files with 82 additions and 84 deletions

View File

@ -16,22 +16,18 @@
package top.charles7c.continew.admin.monitor.model.query;
import cn.hutool.core.date.DatePattern;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.format.annotation.DateTimeFormat;
import cn.hutool.core.date.DatePattern;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
/**
* 操作日志查询条件
*
@ -49,7 +45,7 @@ public class OperationLogQuery implements Serializable {
* 操作内容
*/
@Schema(description = "操作内容", example = "新增数据")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String description;
/**
@ -71,6 +67,6 @@ public class OperationLogQuery implements Serializable {
* 操作人
*/
@Schema(description = "操作人", example = "张三")
@Query(property = "createUser")
@Query(columns = "create_user")
private Long uid;
}

View File

@ -43,13 +43,13 @@ public class AnnouncementQuery implements Serializable {
* 标题
*/
@Schema(description = "标题", example = "这是公告标题")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String title;
/**
* 类型
*/
@Schema(description = "类型", example = "1")
@Query(type = QueryType.EQUAL)
@Query
private String type;
}

View File

@ -43,7 +43,7 @@ public class DeptQuery implements Serializable {
* 名称
*/
@Schema(description = "名称", example = "测试部")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String name;
/**

View File

@ -16,15 +16,14 @@
package top.charles7c.continew.admin.system.model.query;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
import java.io.Serial;
import java.io.Serializable;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
/**
* 字典查询条件
*
@ -42,7 +41,7 @@ public class DictQuery implements Serializable {
* 名称
*/
@Schema(description = "名称")
@Query(blurry = {"code", "name", "description"})
@Query(columns = {"name", "code", "description"}, type = QueryType.LIKE)
private String name;
}

View File

@ -43,13 +43,13 @@ public class FileQuery implements Serializable {
* 名称
*/
@Schema(description = "名称")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String name;
/**
* 类型
*/
@Schema(description = "类型")
@Query(type = QueryType.EQUAL)
@Query
private Integer type;
}

View File

@ -43,7 +43,7 @@ public class MenuQuery implements Serializable {
* 标题
*/
@Schema(description = "标题", example = "用户管理")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String title;
/**

View File

@ -48,7 +48,7 @@ public class MessageQuery implements Serializable {
* 标题
*/
@Schema(description = "标题", example = "欢迎注册 xxx")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String title;
/**

View File

@ -16,15 +16,14 @@
package top.charles7c.continew.admin.system.model.query;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
import java.io.Serial;
import java.io.Serializable;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
/**
* 角色查询条件
*
@ -42,7 +41,7 @@ public class RoleQuery implements Serializable {
* 名称
*/
@Schema(description = "名称", example = "测试人员")
@Query(blurry = {"name", "code"})
@Query(columns = {"name", "code"}, type = QueryType.LIKE)
private String name;
/**

View File

@ -43,13 +43,13 @@ public class StorageQuery implements Serializable {
* 名称
*/
@Schema(description = "名称")
@Query(type = QueryType.INNER_LIKE)
@Query(type = QueryType.LIKE)
private String name;
/**
* 状态
*/
@Schema(description = "状态")
@Query(type = QueryType.EQUAL)
@Query
private Integer status;
}

View File

@ -16,22 +16,18 @@
package top.charles7c.continew.admin.system.model.query;
import cn.hutool.core.date.DatePattern;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.format.annotation.DateTimeFormat;
import cn.hutool.core.date.DatePattern;
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
/**
* 用户查询条件
*
@ -49,7 +45,7 @@ public class UserQuery implements Serializable {
* 用户名
*/
@Schema(description = "用户名", example = "zhangsan")
@Query(blurry = {"username", "nickname", "email", "phone"})
@Query(columns = {"username", "nickname", "email", "phone"}, type = QueryType.LIKE)
private String username;
/**

View File

@ -32,57 +32,70 @@ import top.charles7c.continew.starter.data.mybatis.plus.base.IBaseEnum;
public enum QueryTypeEnum implements IBaseEnum<Integer> {
/**
* 值查询例如WHERE `age` = 18
* =例如WHERE `age` = 18
*/
EQUAL(1, "="),
EQ(1, "="),
/**
* 非等值查询例如WHERE `age` != 18
* 不等于 !=例如WHERE `age` != 18
*/
NOT_EQUAL(2, "!="),
NE(2, "!="),
/**
* 大于查询例如WHERE `age` > 18
* 大于 >例如WHERE `age` > 18
*/
GREATER_THAN(3, ">"),
GT(3, ">"),
/**
* 小于查询例如WHERE `age` < 18
* 大于等于 >= 例如WHERE `age` >= 18
*/
LESS_THAN(4, "<"),
GE(4, ">="),
/**
* 大于等于查询例如WHERE `age` >= 18
* 小于 <例如WHERE `age` < 18
*/
GREATER_THAN_OR_EQUAL(5, ">="),
LT(5, "<"),
/**
* 小于等于查询例如WHERE `age` <= 18
* 小于等于 <=例如WHERE `age` <= 18
*/
LESS_THAN_OR_EQUAL(6, "<="),
LE(6, "<="),
/**
* 范围查询例如WHERE `age` BETWEEN 10 AND 18
*/
BETWEEN(7, "BETWEEN"),
/**
* 左模糊查询例如WHERE `nickname` LIKE '%s'
* LIKE '%%'例如WHERE `nickname` LIKE '%s%'
*/
LEFT_LIKE(8, "LIKE '%s'"),
LIKE(8, "LIKE '%s%'"),
/**
* 中模糊查询例如WHERE `nickname` LIKE '%s%'
* LIKE '%'例如WHERE `nickname` LIKE '%s'
*/
INNER_LIKE(9, "LIKE '%s%'"),
LIKE_LEFT(9, "LIKE '%s'"),
/**
* 右模糊查询例如WHERE `nickname` LIKE 's%'
* LIKE '%'例如WHERE `nickname` LIKE 's%'
*/
RIGHT_LIKE(10, "LIKE 's%'"),
LIKE_RIGHT(10, "LIKE 's%'"),
/**
* 包含查询例如WHERE `age` IN (10, 20, 30)
*/
IN(11, "IN"),
/**
* 不包含查询例如WHERE `age` NOT IN (20, 30)
*/
NOT_IN(12, "NOT IN"),
/**
* 空查询例如WHERE `email` IS NULL
*/
IS_NULL(13, "IS NULL"),
/**
* 非空查询例如WHERE `email` IS NOT NULL
*/

View File

@ -16,31 +16,26 @@
package top.charles7c.continew.admin.tool.model.entity;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.meta.Column;
import cn.hutool.setting.dialect.Props;
import cn.hutool.setting.dialect.PropsUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import top.charles7c.continew.admin.tool.enums.FormTypeEnum;
import top.charles7c.continew.admin.tool.enums.QueryTypeEnum;
import top.charles7c.continew.starter.core.constant.StringConstants;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 字段配置实体
*
@ -160,7 +155,7 @@ public class FieldConfigDO implements Serializable {
this.setShowInForm(isRequired);
this.setShowInQuery(isRequired);
this.setFormType(FormTypeEnum.TEXT);
this.setQueryType("String".equals(this.getFieldType()) ? QueryTypeEnum.INNER_LIKE : QueryTypeEnum.EQUAL);
this.setQueryType("String".equals(this.getFieldType()) ? QueryTypeEnum.LIKE : QueryTypeEnum.EQ);
}
public void setColumnName(String columnName) {