Skip to content

Commit

Permalink
refactor: 调整部分 Query 查询参数类型为对应枚举(目前已支持非 JSON 格式枚举参数转换)
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Jul 31, 2024
1 parent 5b2e3d8 commit f80316e
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class FileStorageConfigLoader implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) {
StorageQuery query = new StorageQuery();
query.setStatus(DisEnableStatusEnum.ENABLE.getValue());
query.setStatus(DisEnableStatusEnum.ENABLE);
List<StorageResp> storageList = storageService.list(query, null);
if (CollUtil.isEmpty(storageList)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.enums.QueryType;

Expand Down Expand Up @@ -47,6 +48,6 @@ public class DeptQuery implements Serializable {
/**
* 状态
*/
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
private Integer status;
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.enums.QueryType;

Expand Down Expand Up @@ -47,8 +48,8 @@ public class DictItemQuery implements Serializable {
/**
* 状态
*/
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
private Integer status;
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;

/**
* 字典 ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.system.enums.FileTypeEnum;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.enums.QueryType;

Expand All @@ -40,13 +41,13 @@ public class FileQuery implements Serializable {
/**
* 名称
*/
@Schema(description = "名称")
@Schema(description = "名称", example = "图片")
@Query(type = QueryType.LIKE)
private String name;

/**
* 类型
*/
@Schema(description = "类型")
private Integer type;
@Schema(description = "类型", example = "2")
private FileTypeEnum type;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import top.continew.admin.common.enums.DisEnableStatusEnum;

import java.io.Serial;
import java.io.Serializable;
Expand Down Expand Up @@ -75,6 +76,6 @@ public class LogQuery implements Serializable {
/**
* 状态
*/
@Schema(description = "状态(1:成功;2:失败)", example = "1")
private Integer status;
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.enums.QueryType;

Expand Down Expand Up @@ -49,10 +50,10 @@ public class MenuQuery implements Serializable {
/**
* 状态
*/
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
private Integer status;
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;

public MenuQuery(Integer status) {
public MenuQuery(DisEnableStatusEnum status) {
this.status = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.enums.MessageTypeEnum;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.annotation.QueryIgnore;
import top.continew.starter.data.core.enums.QueryType;
Expand Down Expand Up @@ -54,8 +55,8 @@ public class MessageQuery implements Serializable {
/**
* 类型
*/
@Schema(description = "类型(1:系统消息)", example = "1")
private Integer type;
@Schema(description = "类型", example = "1")
private MessageTypeEnum type;

/**
* 是否已读
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.enums.QueryType;

Expand Down Expand Up @@ -47,6 +48,6 @@ public class StorageQuery implements Serializable {
/**
* 状态
*/
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
private Integer status;
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import top.continew.admin.common.enums.DisEnableStatusEnum;

import java.io.Serial;
import java.io.Serializable;
Expand Down Expand Up @@ -49,8 +50,8 @@ public class UserQuery implements Serializable {
/**
* 状态
*/
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
private Integer status;
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;

/**
* 创建时间
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.admin.system.mapper.LogMapper;
import top.continew.admin.system.model.entity.LogDO;
import top.continew.admin.system.model.query.LogQuery;
Expand Down Expand Up @@ -151,7 +152,7 @@ private QueryWrapper<LogDO> buildQueryWrapper(LogQuery query) {
String module = query.getModule();
String ip = query.getIp();
String createUserString = query.getCreateUserString();
Integer status = query.getStatus();
DisEnableStatusEnum status = query.getStatus();
List<Date> createTimeList = query.getCreateTime();
return new QueryWrapper<LogDO>().and(StrUtil.isNotBlank(description), q -> q.like("t1.description", description)
.or()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void delete(List<Long> ids) {
@Override
@Cached(key = "'ALL'", name = CacheConstants.MENU_KEY_PREFIX)
public List<MenuResp> listAll() {
return super.list(new MenuQuery(DisEnableStatusEnum.ENABLE.getValue()), null);
return super.list(new MenuQuery(DisEnableStatusEnum.ENABLE), null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ protected <E> List<E> list(UserQuery query, SortQuery sortQuery, Class<E> target
@Override
protected QueryWrapper<UserDO> buildQueryWrapper(UserQuery query) {
String description = query.getDescription();
Integer status = query.getStatus();
DisEnableStatusEnum status = query.getStatus();
List<Date> createTimeList = query.getCreateTime();
Long deptId = query.getDeptId();
return new QueryWrapper<UserDO>().and(StrUtil.isNotBlank(description), q -> q.like("t1.username", description)
Expand Down

0 comments on commit f80316e

Please sign in to comment.