-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectCommunityAnswerEntity.java
More file actions
40 lines (32 loc) · 1.14 KB
/
ProjectCommunityAnswerEntity.java
File metadata and controls
40 lines (32 loc) · 1.14 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
package NextLevel.demo.project.community.entity;
import NextLevel.demo.BasedEntity;
import NextLevel.demo.project.community.dto.request.SaveCommunityDto;
import NextLevel.demo.user.entity.UserEntity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "project_community_answer")
@NoArgsConstructor
@Builder
@AllArgsConstructor
@Getter
public class ProjectCommunityAnswerEntity extends BasedEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String content;
@ManyToOne(targetEntity = UserEntity.class, fetch = FetchType.EAGER)
@JoinColumn(name = "user_id", nullable = false)
private UserEntity user;
@OneToOne(targetEntity = ProjectCommunityAskEntity.class, fetch = FetchType.EAGER)
@JoinColumn(name = "ask_id", nullable = false)
private ProjectCommunityAskEntity ask;
public void update(SaveCommunityDto dto) {
if(dto.getContent() != null && !dto.getContent().isEmpty())
this.content = dto.getContent();
}
}