LandingPageProject.java
2.0 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
package com.aigeo.landingpage.entity;
import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 落地页项目实体类
*/
@Data
@Entity
@Table(name = "ai_landing_page_projects")
public class LandingPageProject {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "company_id")
private Integer companyId;
@Column(name = "user_id")
private Integer userId;
@Column(name = "name")
private String name;
@Enumerated(EnumType.STRING)
@Column(name = "status")
private ProjectStatus status;
@Column(name = "last_step_completed")
private Integer lastStepCompleted;
@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 (status == null) {
status = ProjectStatus.DRAFT;
}
if (lastStepCompleted == null) {
lastStepCompleted = 0;
}
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
/**
* 项目状态枚举
*/
public enum ProjectStatus {
DRAFT("draft"), // 草稿
IN_PROGRESS("in_progress"), // 进行中
COMPLETED("completed"), // 已完成
PUBLISHED("published"); // 已发布
private final String code;
ProjectStatus(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public static ProjectStatus fromCode(String code) {
for (ProjectStatus status : ProjectStatus.values()) {
if (status.getCode().equals(code)) {
return status;
}
}
throw new IllegalArgumentException("未知的项目状态: " + code);
}
}
}