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

[Feature] Task API 작성 (#33) #34

Merged
merged 10 commits into from
Dec 16, 2023
Merged

[Feature] Task API 작성 (#33) #34

merged 10 commits into from
Dec 16, 2023

Conversation

binary-ho
Copy link
Member

@binary-ho binary-ho commented Dec 15, 2023

1. 구현 내용

일단은 평범한 CUD입니다. Task를 생성하고, description과 isDone을 수정하고, 삭제하는 4가지 API를 구현했습니다.


  1. Task의 isDone 기본 값은 false입니다. 이를 깔끔하게 표현하고 싶어 기본 생성자 제한자를 private로 좁히고, 정적 팩터리 메서드를 사용했습니다.
  2. 수정 메서드에는 HTTP Method Patch를 적용했습니다. 2가지 resource를 아래와 같이 접근합니다.
    • "/{taskId}/description"
    • "/{taskId}/isDone"
  3. 매번 Task의 실제 소유자와 요청을 보낸 유저가 같은지 서비스에서 확인합니다. (currentUser)
    코드가 너무 지저분한데, 더 나은 방법이 있는지 고민됩니다...
  4. Entity update에 새로운 객체를 만드는 것이 아닌, 필드들을 var로 선언하여 실제로 수정했습니다.
    처음엔 새로운 객체를 내놓으려 했는데, CreateAt이 변경될 것이 걱정되어 일단 이렇게 구현했습니다.
    더 나은 방법이 있는지 고민됩니다.. 실제로 CreateAt에 직접 값을 대입할 수 있게 만들 수 있다면, 새로운 객체를 반환해도 될 것 같은데, 한번 고민해보겠습니다.
  5. 불안해서 테스트 코드 짰습니다 (후회중)

) : BaseEntity()
) : BaseEntity() {

companion object {
Copy link
Member

Choose a reason for hiding this comment

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

Java에서는 protected 또는 public 생성자가 필요한 걸로 알고 있는데
일단 합치고 추후에 같이 확인해봐요!

Copy link
Member

Choose a reason for hiding this comment

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

의도는 너무 좋은 것 같습니더 :)

Copy link
Member Author

Choose a reason for hiding this comment

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

아 엔티티에 필요한 생성자를 고려하지 못했군요.. 문제가 생길 수 있는지 확인해봐야겠습니다.

return ResponseEntity.ok().build()
}

@PatchMapping("/{taskId}/isDone")
Copy link
Member

Choose a reason for hiding this comment

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

이 부분도 결국 취향이라 생각해서 조심스러운데요..ㅎㅎ
Restful 원칙에서 소문자를 쓰라고 가이드한다는 점과 dash를 사용하라고 가이드하는 점이 봤을 때 /{taskId}/is-done도 한번 고려해봐도 좋을 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

아닙니다 가이드를 지키는 편이 좋아 보입니다. 한번 엔드포인트를 가다듬기는 해야 할텐데 그때 잊지 말고 고쳐 놓아야겠네요..

Copy link
Member

@egg528 egg528 left a comment

Choose a reason for hiding this comment

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

진호님 고생하셨습니다~!

@egg528 egg528 merged commit ae727eb into develop Dec 16, 2023
1 check passed
@binary-ho binary-ho deleted the feature/#33 branch March 25, 2024 14:32
@binary-ho binary-ho self-assigned this May 7, 2024
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.

2 participants