Skip to content
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

Open
wants to merge 6 commits into
base: beomsu
Choose a base branch
from

Conversation

shon5544
Copy link
Member

Feature

  • 게시글 추가
  • 게시글 조회(단일, 전체)

Detail

  • 계층형 아키텍처
    • 최대한 단순하게 나타내려 노력했습니다.
    • 지금 당장은 어떠한 의존성 역전을 쓰지 않겠습니다. 의존성의 흐름 그대로 개발하겠습니다.
    • 추후 한번 리팩토링 해봅시다.
  • 각 기능별 응답 dto 분리
    • 응답 폼이 유사한 것들이 많습니다.
    • 그러나 각 기능들끼리의 강결합을 피하기 위해 분리했습니다.
    • 저는 앞으로도 유지보수성을 고려해 이렇게 작업할 계획입니다.

Todo

  • 테스트 코드

@shon5544 shon5544 changed the base branch from main to beomsu May 25, 2024 17:12
Comment on lines +13 to +25
@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;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostEntity와 BaseTimeEntity로 나누셨는데 이유가 있으신가요? 따로 나눴을때의 이점이 무엇인가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 질문 해주셨는데요 :) 이 프로젝트에서 생성 시간, 수정 시간의 경우 모든 엔티티에 사용하는 필드입니다. 모든 엔티티가 공유하게 될 필드이므로 이를 상속으로 풀어내면 반복을 줄일 수 있겠죠? 그러한 이유로 BaseTimeEntity라는 부모 클래스를 만들어 놓은 것입니다 !

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 나중에 과제로 드릴려고 했는데 잘 구현하셨네요 👍👍

Comment on lines +13 to +25
@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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 나중에 과제로 드릴려고 했는데 잘 구현하셨네요 👍👍

Comment on lines +17 to +18
@Transactional
public PostCreateResponse create(PostCreateRequest request) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent는 4개로 하는게 가독성이 좋을 것 같아요! 구글도 4개의 Indent를 권장한다고 하네요

Comment on lines +11 to +13
@RequiredArgsConstructor
public class PostDeleteService {
private final PostJpaRepository postJpaRepository;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서비스를 이렇게 세세하게 분리하면 어떤 장단점이 있을까요?

Comment on lines +17 to +19
public class PostRetrieveService {
// FIXME: jpa와의 강결합
private final PostJpaRepository postJpaRepository;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만약 결합을 느슨하게 하고 싶다면 어떤 방식으로 수정하실 생각인가요?

Comment on lines +23 to +27
public static PostEntity of(PostCreateRequest request) {
return PostEntity.builder()
.title(request.getTitle())
.content(request.getContent())
.build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent는 컨벤션으로 일정하게 유지하는게 가독성이 좋습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants