-
Notifications
You must be signed in to change notification settings - Fork 3
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] contents 공통 코드 작성 #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package wanted.media.content.controller; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Controller | ||
@RequestMapping("/contents") | ||
public class ContentController { | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 EOL에 대해서 아시나용? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package wanted.media.content.domain; | ||
|
||
import jakarta.persistence.*; | ||
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; | ||
import wanted.media.user.domain.User; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@Table(name="contents") | ||
@NoArgsConstructor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NoArgsConstructor를 @NoArgsConstructor (access = AccessLevel.PROTECTED) 로 변경하면 어떨지 제안합니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 어떤 설정인가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기본 access 설정은 AccessLevel.PUBLIC이고, 별도로 access 속성을 설정하지 않으면 public 접근 수준으로 기본 생성자가 만들어진다고 합니다. |
||
@AllArgsConstructor | ||
@Builder | ||
@ToString | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@EntityListeners(AuditingEntityListener.class) | ||
public class Content { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GenerationType을 SEQUENCE로 하신 이유가 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 찾아보니 오라클 등은 sequence를 주로 사용하고 mysql의 경우에는 IDENTITY를 사용한다고 하네요! 수정하겠습니다. |
||
@Column(name = "content_id", nullable = false) | ||
private Long id; | ||
private Long likeCount; | ||
@Size(max = 50) | ||
private String type; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type은 String이 아니라 Enum이네요 ! |
||
@Size(max = 150) | ||
private String title; | ||
private String content; | ||
private String hashtags; | ||
private Long viewCount; | ||
private Long shareCount; | ||
@LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@ManyToOne | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@JoinColumn(name = "user_id") | ||
@NotNull | ||
private User user; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package wanted.media.content.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import wanted.media.content.domain.Content; | ||
|
||
public interface ContentRepository extends JpaRepository<Content,Long> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package wanted.media.content.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ContentService { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package wanted.media.user.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
import wanted.media.content.domain.Content; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Entity | ||
@Table(name="users") | ||
public class User { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@Column(name = "userId", nullable = false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 user_id로 통일해도 될까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 알겠습니다! |
||
private UUID userId; | ||
|
||
@OneToMany(mappedBy = "user") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거는 단방향 연관관계와 양방향 연관관계를 알아보시고, 어떻게 사용할지 저희끼리 회의를 해야할 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 양방향 연관관계에 대한 논의가 필요하다고 생각합니다! |
||
@Builder.Default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재는 필요없는 설정이라 삭제하겠습니다. |
||
List<Content> interviews = new ArrayList<>(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RestController
대신@Controller
를 사용하신 이유가 있을까요??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RestController로 수정하겠습니다.