AutoMedinfo/backend/src/main/java/com/ipsen/medical/entity/SearchResultItem.java

118 lines
2.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.ipsen.medical.entity;
import javax.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 检索结果项实体
* 用于存储单条检索结果,支持用户对每条结果进行标记和处理
*/
@Data
@Entity
@Table(name = "search_result_items")
public class SearchResultItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "inquiry_request_id", nullable = false)
private InquiryRequest inquiryRequest;
@Column(nullable = false)
private String title; // 标题
@Column(columnDefinition = "TEXT")
private String summary; // 摘要
@Column(columnDefinition = "TEXT")
private String content; // 内容
private String authors; // 作者
private String source; // 来源知网、ClinicalTrials、知识库等
private String sourceUrl; // 来源URL
private String publicationDate; // 发表日期
private String doi; // DOI
private String pmid; // PubMed ID
private String nctId; // ClinicalTrials NCT ID
@Column(columnDefinition = "TEXT")
private String metadata; // 其他元数据JSON格式
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private ResultStatus status; // 结果状态
private Boolean includeInResponse; // 是否纳入回复参考资料
private Boolean needDownload; // 是否需要下载全文
private Boolean isDeleted; // 是否标记为错误并删除
private String filePath; // 下载后的文件路径
@Enumerated(EnumType.STRING)
private DownloadStatus downloadStatus; // 下载状态
@Column(nullable = false)
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
private LocalDateTime downloadedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
if (includeInResponse == null) {
includeInResponse = false;
}
if (needDownload == null) {
needDownload = false;
}
if (isDeleted == null) {
isDeleted = false;
}
if (status == null) {
status = ResultStatus.PENDING_REVIEW;
}
if (downloadStatus == null) {
downloadStatus = DownloadStatus.NOT_REQUIRED;
}
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
public enum ResultStatus {
PENDING_REVIEW, // 待审核
APPROVED, // 已批准
REJECTED, // 已拒绝
DELETED // 已删除(错误信息)
}
public enum DownloadStatus {
NOT_REQUIRED, // 不需要下载
PENDING, // 待下载
DOWNLOADING, // 下载中
COMPLETED, // 已完成
FAILED // 失败
}
}