diff --git a/src/main/java/com/example/helloworldmvc/domain/Comment.java b/src/main/java/com/example/helloworldmvc/domain/Comment.java new file mode 100644 index 0000000..42c4273 --- /dev/null +++ b/src/main/java/com/example/helloworldmvc/domain/Comment.java @@ -0,0 +1,22 @@ +package com.example.helloworldmvc.domain; + +import com.example.helloworldmvc.domain.common.BaseEntity; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class Comment extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + private String content; + + @ManyToOne(fetch = FetchType.LAZY) + private User user; +} diff --git a/src/main/java/com/example/helloworldmvc/domain/Community.java b/src/main/java/com/example/helloworldmvc/domain/Community.java new file mode 100644 index 0000000..55f407f --- /dev/null +++ b/src/main/java/com/example/helloworldmvc/domain/Community.java @@ -0,0 +1,37 @@ +package com.example.helloworldmvc.domain; + +import com.example.helloworldmvc.domain.common.BaseEntity; +import com.example.helloworldmvc.domain.enums.CommunityCategory; +import jakarta.persistence.*; +import lombok.*; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class Community extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + private String title; + + @Column(nullable = false) + private String content; + + @Enumerated(EnumType.STRING) + @Column(columnDefinition = "VARCHAR(10) DEFAULT 'ETC'") + private CommunityCategory communityCategory; + + @ManyToOne(fetch = FetchType.LAZY) + private User user; + + @OneToMany(mappedBy = "community", cascade = CascadeType.ALL) + private List fileList = new ArrayList<>(); + +} diff --git a/src/main/java/com/example/helloworldmvc/domain/File.java b/src/main/java/com/example/helloworldmvc/domain/File.java index 9c4f6e3..197bd22 100644 --- a/src/main/java/com/example/helloworldmvc/domain/File.java +++ b/src/main/java/com/example/helloworldmvc/domain/File.java @@ -23,6 +23,9 @@ public class File { @JoinColumn(name = "center_id") private Center center; + @ManyToOne(fetch = FetchType.LAZY) + private Community community; + public void setUrl(String imageUrl){ this.url = imageUrl; } diff --git a/src/main/java/com/example/helloworldmvc/domain/User.java b/src/main/java/com/example/helloworldmvc/domain/User.java index 5003382..6345f5a 100644 --- a/src/main/java/com/example/helloworldmvc/domain/User.java +++ b/src/main/java/com/example/helloworldmvc/domain/User.java @@ -44,6 +44,12 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List userLanguageList = new ArrayList<>(); + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List commentList = new ArrayList<>(); + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List communityList = new ArrayList<>(); + public User update(String name) { this.name = name; diff --git a/src/main/java/com/example/helloworldmvc/domain/enums/CommunityCategory.java b/src/main/java/com/example/helloworldmvc/domain/enums/CommunityCategory.java new file mode 100644 index 0000000..1976016 --- /dev/null +++ b/src/main/java/com/example/helloworldmvc/domain/enums/CommunityCategory.java @@ -0,0 +1,6 @@ +package com.example.helloworldmvc.domain.enums; + +public enum CommunityCategory { + // 직장 내 고충, 산재 및 의료, 체류 및 근로 자격, 기타 + WORRY, MEDICAL, QUALIFICATION, ETC +}