Skip to content

Commit

Permalink
#61 Feat : 카테고리 엔티티 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ls-rain committed Feb 3, 2024
1 parent 8001bbe commit 9398bc8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/friend/spring/domain/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package friend.spring.domain;

import friend.spring.domain.common.BaseEntity;
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Category extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 10)
private String name;

@Builder.Default
@OneToMany(mappedBy = "category")
private List<Post> postList = new ArrayList<>();
}
3 changes: 3 additions & 0 deletions src/main/java/friend/spring/domain/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class Post extends BaseEntity {
@JoinColumn(name = "user_id")
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "category_id")
private Category postCategory;
// 부모 글 정의
// 고민후기 원글 아이디
@ManyToOne(fetch = FetchType.LAZY)
Expand Down

0 comments on commit 9398bc8

Please sign in to comment.