-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPost.java
94 lines (70 loc) · 2.84 KB
/
Post.java
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
package com.codiary.backend.global.domain.entity;
import com.codiary.backend.global.domain.common.BaseEntity;
import com.codiary.backend.global.domain.entity.mapping.Authors;
import com.codiary.backend.global.domain.entity.mapping.Categories;
import com.codiary.backend.global.domain.enums.PostAccess;
import com.codiary.backend.global.web.dto.Post.PostRequestDTO;
import jakarta.persistence.*;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Post extends BaseEntity {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "post_id", nullable = false,columnDefinition = "bigint")
private Long postId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "team_id")
private Team team;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "project_id")
private Project project;
@Column(name = "post_category", columnDefinition = "varchar(500)")
private String postCategory;
@Column(name = "post_title", nullable = false, columnDefinition = "varchar(500)")
private String postTitle;
@Column(name = "post_body", nullable = false, columnDefinition = "varchar(500)")
private String postBody;
@Builder.Default
@Enumerated(EnumType.STRING)
@Column(name = "post_access", nullable = false, columnDefinition = "varchar(500)")
private PostAccess postAccess = PostAccess.MEMBER;
@Column(name = "post_status", nullable = false, columnDefinition = "tinyint")
private Boolean postStatus;
@Builder.Default
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PostPhoto> postPhotoList = new ArrayList<>();
@Builder.Default
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Categories> catecoriesList = new ArrayList<>();
@Builder.Default
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Authors> authorsList = new ArrayList<>();
@Builder.Default
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> commentList = new ArrayList<>();
public void setMember(Member member) {
this.member = member;
}
public void setTeam(Team team) {
this.team = team;
}
public void setProject(Project project) { this.project = project;}
public void update(PostRequestDTO.UpdatePostDTO request) {
this.postTitle = request.getPostTitle();
this.postBody = request.getPostBody();
this.postAccess = request.getPostAccess();
this.postStatus = request.getPostStatus();
this.postCategory = request.getPostCategory();
}
public void setPostStatus(Boolean postStatus) {
this.postStatus = postStatus;
}
}