diff --git a/src/main/java/wanted/media/content/controller/ContentController.java b/src/main/java/wanted/media/content/controller/ContentController.java index 025e10a..00583de 100644 --- a/src/main/java/wanted/media/content/controller/ContentController.java +++ b/src/main/java/wanted/media/content/controller/ContentController.java @@ -1,9 +1,9 @@ package wanted.media.content.controller; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController @RequestMapping("/contents") public class ContentController { } diff --git a/src/main/java/wanted/media/content/domain/Content.java b/src/main/java/wanted/media/content/domain/Content.java index 0ef7ad2..fed9efd 100644 --- a/src/main/java/wanted/media/content/domain/Content.java +++ b/src/main/java/wanted/media/content/domain/Content.java @@ -4,7 +4,6 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.*; - import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -14,33 +13,43 @@ @Entity @Getter -@Setter -@Table(name="contents") -@NoArgsConstructor +@Table(name = "contents") +@NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor @Builder -@ToString @EntityListeners(AuditingEntityListener.class) public class Content { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "content_id", nullable = false) private Long id; + + @Column(name = "like_count") private Long likeCount; - @Size(max = 50) - private String type; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private Type type; + @Size(max = 150) + @Column(nullable = false) private String title; + private String content; + private String hashtags; + private Long viewCount; + private Long shareCount; + @LastModifiedDate private LocalDateTime updatedAt; + @CreatedDate private LocalDateTime createdAt; - @ManyToOne + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") @NotNull private User user; diff --git a/src/main/java/wanted/media/content/domain/Type.java b/src/main/java/wanted/media/content/domain/Type.java new file mode 100644 index 0000000..539f7fa --- /dev/null +++ b/src/main/java/wanted/media/content/domain/Type.java @@ -0,0 +1,5 @@ +package wanted.media.content.domain; + +public enum Type { + FACEBOOK, TWITTER, INSTAGRAM, THREADS; +} diff --git a/src/main/java/wanted/media/content/repository/ContentRepository.java b/src/main/java/wanted/media/content/repository/ContentRepository.java index 06eaa31..510a593 100644 --- a/src/main/java/wanted/media/content/repository/ContentRepository.java +++ b/src/main/java/wanted/media/content/repository/ContentRepository.java @@ -3,5 +3,5 @@ import org.springframework.data.jpa.repository.JpaRepository; import wanted.media.content.domain.Content; -public interface ContentRepository extends JpaRepository { +public interface ContentRepository extends JpaRepository { } diff --git a/src/main/java/wanted/media/user/domain/User.java b/src/main/java/wanted/media/user/domain/User.java index 6da7d1a..4e2b0a0 100644 --- a/src/main/java/wanted/media/user/domain/User.java +++ b/src/main/java/wanted/media/user/domain/User.java @@ -6,10 +6,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import wanted.media.content.domain.Content; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; @NoArgsConstructor @@ -21,13 +18,9 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.UUID) - @Column(name = "userId", nullable = false) + @Column(name = "user_id", nullable = false) private UUID userId; - @OneToMany(mappedBy = "user") - @Builder.Default - List interviews = new ArrayList<>(); - @Column(unique = true, nullable = false) @Size(max = 50) private String account;