Skip to content

Commit

Permalink
Merge pull request #27 from Gongjakso/feat/entity
Browse files Browse the repository at this point in the history
feat: Category Entity 생성
  • Loading branch information
dl-00-e8 authored Feb 2, 2024
2 parents ce54208 + 72a0f63 commit 1ea60d5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.gongjakso.server.domain.post.entity;

import com.gongjakso.server.domain.post.enumerate.CategoryType;
import com.gongjakso.server.global.common.BaseTimeEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "category")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Category extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "category_id", nullable = false, columnDefinition = "bigint")
private Long categoryId;

@ManyToOne
@JoinColumn(name = "post_id", nullable = false, columnDefinition = "bigint")
private Post post;

@Column(name = "category_type", nullable = false, columnDefinition = "varchar(100)")
@Enumerated(EnumType.STRING)
private CategoryType categoryType;

@Column(name = "size", nullable = false, columnDefinition = "int")
private Integer size;

@Builder
public Category(Post post, String categoryType, Integer size) {
this.post = post;
this.categoryType = CategoryType.valueOf(categoryType);
this.size = size;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.gongjakso.server.domain.post.enumerate;

public enum CategoryType {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gongjakso.server.domain.post.repository;

import com.gongjakso.server.domain.post.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CategoryRepository extends JpaRepository<Category, Long> {

}

0 comments on commit 1ea60d5

Please sign in to comment.