-
Notifications
You must be signed in to change notification settings - Fork 1
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
[2주차] 손범수: 게시글 관련 API #4
base: beomsu
Are you sure you want to change the base?
Conversation
@EntityListeners(AuditingEntityListener.class) | ||
@MappedSuperclass | ||
@Getter | ||
public abstract class BaseTimeEntity { | ||
|
||
@CreatedDate | ||
@Column(name = "created_at", nullable = false, updatable = false) | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
@Column(name = "updated_at", nullable = false, updatable = false) | ||
private LocalDateTime updatedAt; | ||
} |
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.
PostEntity와 BaseTimeEntity로 나누셨는데 이유가 있으신가요? 따로 나눴을때의 이점이 무엇인가요?
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.
좋은 질문 해주셨는데요 :) 이 프로젝트에서 생성 시간, 수정 시간의 경우 모든 엔티티에 사용하는 필드입니다. 모든 엔티티가 공유하게 될 필드이므로 이를 상속으로 풀어내면 반복을 줄일 수 있겠죠? 그러한 이유로 BaseTimeEntity라는 부모 클래스를 만들어 놓은 것입니다 !
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.
이것도 나중에 과제로 드릴려고 했는데 잘 구현하셨네요 👍👍
@EntityListeners(AuditingEntityListener.class) | ||
@MappedSuperclass | ||
@Getter | ||
public abstract class BaseTimeEntity { | ||
|
||
@CreatedDate | ||
@Column(name = "created_at", nullable = false, updatable = false) | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
@Column(name = "updated_at", nullable = false, updatable = false) | ||
private LocalDateTime updatedAt; | ||
} |
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.
이것도 나중에 과제로 드릴려고 했는데 잘 구현하셨네요 👍👍
@Transactional | ||
public PostCreateResponse create(PostCreateRequest request) { |
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.
indent는 4개로 하는게 가독성이 좋을 것 같아요! 구글도 4개의 Indent를 권장한다고 하네요
@RequiredArgsConstructor | ||
public class PostDeleteService { | ||
private final PostJpaRepository postJpaRepository; |
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 PostRetrieveService { | ||
// FIXME: jpa와의 강결합 | ||
private final PostJpaRepository postJpaRepository; |
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 static PostEntity of(PostCreateRequest request) { | ||
return PostEntity.builder() | ||
.title(request.getTitle()) | ||
.content(request.getContent()) | ||
.build(); |
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.
Indent는 컨벤션으로 일정하게 유지하는게 가독성이 좋습니다!
Feature
Detail
Todo