GeneratedArticle.java
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.aigeo.article.entity;
import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 生成的文章实体类
*/
@Data
@Entity
@Table(name = "ai_generated_articles")
public class GeneratedArticle {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "task_id")
private Integer taskId;
@Column(name = "company_id")
private Integer companyId;
@Column(name = "version")
private Integer version;
@Column(name = "title")
private String title;
@Column(name = "content", columnDefinition = "TEXT")
private String content;
@Column(name = "html_content", columnDefinition = "TEXT")
private String htmlContent;
@Column(name = "faq_section", columnDefinition = "TEXT")
private String faqSection;
@Column(name = "structured_data", columnDefinition = "TEXT")
private String structuredData;
@Column(name = "word_count")
private Integer wordCount;
@Column(name = "keyword_density", columnDefinition = "TEXT")
private String keywordDensity;
@Column(name = "is_selected")
private Boolean isSelected;
@Enumerated(EnumType.STRING)
@Column(name = "status")
private ArticleStatus status;
@Column(name = "created_at")
private LocalDateTime createdAt;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
if (version == null) {
version = 1;
}
if (isSelected == null) {
isSelected = false;
}
if (status == null) {
status = ArticleStatus.DRAFT;
}
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
/**
* 文章状态枚举
*/
public enum ArticleStatus {
DRAFT("draft"), // 草稿
REVIEW("review"), // 审核中
PUBLISHED("published"), // 已发布
ARCHIVED("archived"); // 已归档
private final String code;
ArticleStatus(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public static ArticleStatus fromCode(String code) {
for (ArticleStatus status : ArticleStatus.values()) {
if (status.getCode().equals(code)) {
return status;
}
}
throw new IllegalArgumentException("未知的文章状态: " + code);
}
}
}