Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat/#110] Community 엔티티 생성 #111

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/com/example/helloworldmvc/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -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;
}
37 changes: 37 additions & 0 deletions src/main/java/com/example/helloworldmvc/domain/Community.java
Original file line number Diff line number Diff line change
@@ -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<File> fileList = new ArrayList<>();

}
3 changes: 3 additions & 0 deletions src/main/java/com/example/helloworldmvc/domain/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/example/helloworldmvc/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public class User extends BaseEntity {
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<UserLanguage> userLanguageList = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Comment> commentList = new ArrayList<>();

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Community> communityList = new ArrayList<>();

public User update(String name) {
this.name = name;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.helloworldmvc.domain.enums;

public enum CommunityCategory {
// 직장 내 고충, 산재 및 의료, 체류 및 근로 자격, 기타
WORRY, MEDICAL, QUALIFICATION, ETC
}
Loading