refactor: 优化 Query 相关注解使用方式
This commit is contained in:
parent
9648cf64a4
commit
15b152008c
@ -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,6 @@ public class LoginLogQuery implements Serializable {
|
||||
* 登录状态
|
||||
*/
|
||||
@Schema(description = "登录状态(1:成功;2:失败)", example = "1")
|
||||
@Query
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,6 @@ public class OperationLogQuery implements Serializable {
|
||||
* 操作状态
|
||||
*/
|
||||
@Schema(description = "操作状态(1:成功;2:失败)", example = "1")
|
||||
@Query
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ import top.charles7c.continew.admin.monitor.model.resp.*;
|
||||
import top.charles7c.continew.admin.monitor.service.LogService;
|
||||
import top.charles7c.continew.starter.core.util.ReflectUtils;
|
||||
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryHelper;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;
|
||||
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.PageResp;
|
||||
|
||||
@ -58,7 +58,7 @@ public class LogServiceImpl implements LogService {
|
||||
@Override
|
||||
@AutoOperate(type = OperationLogResp.class, on = "list")
|
||||
public PageResp<OperationLogResp> page(OperationLogQuery query, PageQuery pageQuery) {
|
||||
QueryWrapper<LogDO> queryWrapper = QueryHelper.build(query);
|
||||
QueryWrapper<LogDO> queryWrapper = QueryWrapperHelper.build(query);
|
||||
// 限定查询信息
|
||||
List<String> fieldNameList = ReflectUtils.getNonStaticFieldsName(OperationLogResp.class);
|
||||
List<String> columnNameList = fieldNameList.stream()
|
||||
@ -74,7 +74,7 @@ public class LogServiceImpl implements LogService {
|
||||
@Override
|
||||
@AutoOperate(type = LoginLogResp.class, on = "list")
|
||||
public PageResp<LoginLogResp> page(LoginLogQuery query, PageQuery pageQuery) {
|
||||
QueryWrapper<LogDO> queryWrapper = QueryHelper.build(query);
|
||||
QueryWrapper<LogDO> queryWrapper = QueryWrapperHelper.build(query);
|
||||
queryWrapper.eq("module", "登录");
|
||||
// 限定查询信息
|
||||
List<String> fieldNameList = ReflectUtils.getNonStaticFieldsName(LoginLogResp.class);
|
||||
@ -91,7 +91,7 @@ public class LogServiceImpl implements LogService {
|
||||
@Override
|
||||
@AutoOperate(type = SystemLogResp.class, on = "list")
|
||||
public PageResp<SystemLogResp> page(SystemLogQuery query, PageQuery pageQuery) {
|
||||
QueryWrapper<LogDO> queryWrapper = QueryHelper.build(query);
|
||||
QueryWrapper<LogDO> queryWrapper = QueryWrapperHelper.build(query);
|
||||
// 限定查询信息
|
||||
List<String> fieldNameList = ReflectUtils.getNonStaticFieldsName(SystemLogResp.class);
|
||||
List<String> columnNameList = fieldNameList.stream()
|
||||
|
@ -16,22 +16,18 @@
|
||||
|
||||
package top.charles7c.continew.admin.auth.model.resp;
|
||||
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import top.charles7c.continew.admin.common.enums.GenderEnum;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
|
||||
import top.charles7c.continew.admin.common.enums.GenderEnum;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
|
@ -16,16 +16,14 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 公告查询条件
|
||||
*
|
||||
@ -50,6 +48,5 @@ public class AnnouncementQuery implements Serializable {
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型", example = "1")
|
||||
@Query
|
||||
private String type;
|
||||
}
|
@ -16,16 +16,14 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 部门查询条件
|
||||
*
|
||||
@ -50,6 +48,5 @@ public class DeptQuery implements Serializable {
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -16,14 +16,11 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.Query;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 字典项查询条件
|
||||
@ -42,6 +39,5 @@ public class DictItemQuery implements Serializable {
|
||||
* 字典 ID
|
||||
*/
|
||||
@Schema(description = "字典 ID")
|
||||
@Query
|
||||
private Long dictId;
|
||||
}
|
@ -16,16 +16,14 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 文件查询条件
|
||||
*
|
||||
@ -50,6 +48,5 @@ public class FileQuery implements Serializable {
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型")
|
||||
@Query
|
||||
private Integer type;
|
||||
}
|
@ -16,16 +16,14 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 菜单查询条件
|
||||
*
|
||||
@ -50,6 +48,5 @@ public class MenuQuery implements Serializable {
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -16,15 +16,14 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
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.QueryIgnore;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 消息查询条件
|
||||
*
|
||||
@ -41,7 +40,6 @@ public class MessageQuery implements Serializable {
|
||||
* ID
|
||||
*/
|
||||
@Schema(description = "ID", example = "1")
|
||||
@Query
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -55,18 +53,19 @@ public class MessageQuery implements Serializable {
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型(1:系统消息)", example = "1")
|
||||
@Query
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
@Schema(description = "是否已读", example = "true")
|
||||
@QueryIgnore
|
||||
private Boolean isRead;
|
||||
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
@Schema(hidden = true)
|
||||
@QueryIgnore
|
||||
private Long userId;
|
||||
}
|
@ -48,6 +48,5 @@ public class RoleQuery implements Serializable {
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -16,16 +16,14 @@
|
||||
|
||||
package top.charles7c.continew.admin.system.model.query;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 存储库查询条件
|
||||
*
|
||||
@ -50,6 +48,5 @@ public class StorageQuery implements Serializable {
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态")
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
@ -52,7 +52,6 @@ public class UserQuery implements Serializable {
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态(1:启用;2:禁用)", example = "1")
|
||||
@Query
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
@ -67,6 +66,5 @@ public class UserQuery implements Serializable {
|
||||
* 部门 ID
|
||||
*/
|
||||
@Schema(description = "部门 ID", example = "1")
|
||||
@Query
|
||||
private Long deptId;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import top.charles7c.continew.admin.system.model.resp.MessageResp;
|
||||
import top.charles7c.continew.admin.system.service.MessageService;
|
||||
import top.charles7c.continew.admin.system.service.MessageUserService;
|
||||
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryHelper;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;
|
||||
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.PageResp;
|
||||
|
||||
@ -54,7 +54,7 @@ public class MessageServiceImpl implements MessageService {
|
||||
@Override
|
||||
@AutoOperate(type = MessageResp.class, on = "list")
|
||||
public PageResp<MessageResp> page(MessageQuery query, PageQuery pageQuery) {
|
||||
QueryWrapper<MessageDO> queryWrapper = QueryHelper.build(query);
|
||||
QueryWrapper<MessageDO> queryWrapper = QueryWrapperHelper.build(query);
|
||||
queryWrapper.apply(null != query.getUserId(), "t2.user_id={0}", query.getUserId())
|
||||
.apply(null != query.getIsRead(), "t2.is_read={0}", query.getIsRead());
|
||||
IPage<MessageResp> page = baseMapper.selectPageByUserId(pageQuery.toPage(), queryWrapper);
|
||||
|
@ -28,7 +28,7 @@ import top.charles7c.continew.admin.system.model.req.OptionReq;
|
||||
import top.charles7c.continew.admin.system.model.req.OptionResetValueReq;
|
||||
import top.charles7c.continew.admin.system.model.resp.OptionResp;
|
||||
import top.charles7c.continew.admin.system.service.OptionService;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryHelper;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -46,7 +46,7 @@ public class OptionServiceImpl implements OptionService {
|
||||
|
||||
@Override
|
||||
public List<OptionResp> list(OptionQuery query) {
|
||||
return BeanUtil.copyToList(baseMapper.selectList(QueryHelper.build(query)), OptionResp.class);
|
||||
return BeanUtil.copyToList(baseMapper.selectList(QueryWrapperHelper.build(query)), OptionResp.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user