-
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
Conversation
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.
고생하셨습니다 !
추가로 User와 Content의 커밋은 나누는게 좋을 것 같아요 ! 한 커밋에는 한가지 문제만 담는게 좋습니다!
브랜치명도 feat/contents 보다는 feat/create_content_entity 이런식으로 명확하게 작성하시는게 이해가 쉬울 것 같습니다~
@Controller | ||
@RequestMapping("/contents") | ||
public class ContentController { | ||
} |
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.
혹시 EOL에 대해서 아시나용?
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@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
대신 @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로 수정하겠습니다.
|
||
@Entity | ||
@Getter | ||
@Setter |
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.
@Setter
를 사용하신 이유가 있을까요?
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@ToString |
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.
@ToString
도 당장은 사용할 필요가 없어보여요 !
@EntityListeners(AuditingEntityListener.class) | ||
public class Content { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE) |
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.
GenerationType을 SEQUENCE로 하신 이유가 있을까요?
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.
찾아보니 오라클 등은 sequence를 주로 사용하고 mysql의 경우에는 IDENTITY를 사용한다고 하네요! 수정하겠습니다.
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@ManyToOne |
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.
@ManyToOne
을 사용하실 때 즉시로딩과 지연로딩에 대해서 들어보신 적 있을까요!?
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 comment
The reason will be displayed to describe this comment to others. Learn more.
type은 String이 아니라 Enum이네요 !
@Column(name = "userId", nullable = false) | ||
private UUID userId; | ||
|
||
@OneToMany(mappedBy = "user") |
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.
이거는 단방향 연관관계와 양방향 연관관계를 알아보시고, 어떻게 사용할지 저희끼리 회의를 해야할 것 같습니다!
private UUID userId; | ||
|
||
@OneToMany(mappedBy = "user") | ||
@Builder.Default |
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.
@Builder.Default
는 처음보네요 ! 왜 사용하셨는지 궁금합니당💭
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.
현재는 필요없는 설정이라 삭제하겠습니다.
@Column(name = "userId", nullable = false) | ||
private UUID userId; | ||
|
||
@OneToMany(mappedBy = "user") |
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.
저도 양방향 연관관계에 대한 논의가 필요하다고 생각합니다!
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.
고생하셨습니다!
@Getter | ||
@Setter | ||
@Table(name="contents") | ||
@NoArgsConstructor |
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.
@NoArgsConstructor를 @NoArgsConstructor (access = AccessLevel.PROTECTED) 로 변경하면 어떨지 제안합니다.
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.
혹시 어떤 설정인가요?
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.
기본 access 설정은 AccessLevel.PUBLIC이고, 별도로 access 속성을 설정하지 않으면 public 접근 수준으로 기본 생성자가 만들어진다고 합니다.
다른 패키지에서 엔티티에 대한 접근이 너무 자유로우면 안될것 같다고 생각해서 protected로 설정을 추가하자고 제안했던거였습니다.
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.
고생하셨습니다!
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
네 알겠습니다!
다 확인했습니다! 감사합니다! |
Issue
PR 타입(하나 이상의 PR 타입을 선택해주세요)
반영 브랜치
feat/contents -> dev
변경 사항
공통 코드 작성