1、数据查询的二次查询

This commit is contained in:
2026-03-12 19:35:35 +08:00
parent 72b400b890
commit 36cb0b99c4
5 changed files with 67 additions and 8 deletions

View File

@@ -0,0 +1,56 @@
package com.sdm.common.entity.req.project;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonSetter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Data
public class BaseReq {
@Schema(description = "当前页码")
@NotNull(message = "当前页码不能为空")
private Integer current;
@Schema(description = "每页显示数量")
@NotNull(message = "每页显示数量不能为空")
private Integer size;
@Schema(description = "文件创建搜索开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String startTime;
@Schema(description = "文件创建搜索结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String endTime;
@Schema(description = "创建时间范围,格式为 ['开始时间', '结束时间']")
private List<String> createTime;
// 使用 @JsonSetter 注解确保 JSON 反序列化时调用此方法
@JsonSetter("createTime")
public void setCreateTime(List<String> createTime) {
this.createTime = createTime;
parseCreateTimeToStartEndTime();
}
/**
* 解析 createTime 并赋值给 startTime 和 endTime
*/
private void parseCreateTimeToStartEndTime() {
if (createTime != null && createTime.size() == 2) {
try {
// 解析时间字符串为 LocalDateTime
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
this.startTime = createTime.get(0);
this.endTime = createTime.get(1);
} catch (Exception e) {
throw new IllegalArgumentException("createTime 时间格式错误,请使用 'yyyy-MM-dd HH:mm:ss' 格式");
}
}
}
}