新增了标签搜索
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
package com.example.caseData.request.clinicalRequest;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class getClinicalLabelSearchPage {
|
||||
// ✅ 分页参数
|
||||
@Min(value = 1, message = "页码最小为 1")
|
||||
private Integer page = 1;
|
||||
|
||||
@JsonProperty("page_size")
|
||||
@Min(value = 1, message = "每页个数最小为 1")
|
||||
private Integer pageSize = 20;
|
||||
|
||||
// 疾病标签名称
|
||||
@JsonProperty("label_name")
|
||||
private String labelName;
|
||||
|
||||
// 排序字段
|
||||
private OrderRequest order;
|
||||
|
||||
/**
|
||||
* 排序字段嵌套结构体
|
||||
*/
|
||||
@Data
|
||||
public static class OrderRequest {
|
||||
@JsonProperty("updated_at")
|
||||
private String updatedAt; // 更新时间排序
|
||||
|
||||
@JsonProperty("label_name")
|
||||
private String labelName; // 医院名称
|
||||
|
||||
@JsonProperty("article_num")
|
||||
private String articleNum; // 数量-文章
|
||||
|
||||
|
||||
public Map<String, String> toMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (StringUtils.hasText(updatedAt)) {
|
||||
map.put("a.updated_at", updatedAt);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(labelName)) {
|
||||
map.put("b.label_name", labelName);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(articleNum)) {
|
||||
map.put("a.article_num", articleNum);
|
||||
}
|
||||
|
||||
// 默认排序(如果用户未传递任何排序字段)
|
||||
if (map.isEmpty()) {
|
||||
map.put("a.updated_at", "desc");
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排序字段,若无用户输入则使用默认排序
|
||||
*/
|
||||
public Map<String, String> handleOrder() {
|
||||
return order != null ? order.toMap() : new OrderRequest().toMap();
|
||||
}
|
||||
|
||||
// ✅ 校验分页参数
|
||||
public void validateForPage() {
|
||||
// 如果 page 为空,设为默认值 1
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
if (pageSize == null) {
|
||||
pageSize = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user