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
[jinyoungchoi95-issue63] Article 단일조회 /수정 / 삭제 기능 구현 #64
Conversation
- osiv 임시 true 전환 - GET /api/articles/{slug} permit all 변경
Codecov Report
@@ Coverage Diff @@
## jinyoungchoi95 #64 +/- ##
====================================================
+ Coverage 90.57% 91.58% +1.01%
- Complexity 289 314 +25
====================================================
Files 47 49 +2
Lines 753 808 +55
Branches 29 29
====================================================
+ Hits 682 740 +58
+ Misses 33 30 -3
Partials 38 38
Continue to review full report at Codecov.
|
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.
LGTM!
Article article = articleService.findBySlug(Slug.of(slug)); | ||
return ResponseEntity.ok().body(ArticleResponse.fromArticle(article)); | ||
} | ||
|
||
@PostMapping("/articles") | ||
public ResponseEntity<ArticleResponse> createArticle(@RequestBody ArticleCreateRequest request, | ||
@AuthenticationPrincipal Long loginId) { | ||
Article article = articleService.createArticle(loginId, request.toArticleContent()); | ||
return ResponseEntity.ok().body(ArticleResponse.fromArticle(article)); |
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.
API 명세가 어떻게 되어있는지 확인해야하는데
제가 요번에 안 지식으로 생성로직에서는 create() 하면서 URL 넘기더라고요(이건 참고)
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.
생성하는 경우에는 201 반환하는 것도 좋은 것 같네요 :)
public ResponseEntity<ArticleResponse> updateArticle(@PathVariable String slug, | ||
@RequestBody ArticleUpdateRequest request, @AuthenticationPrincipal Long loginId) { |
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 ResponseEntity<ArticleResponse> updateArticle(@PathVariable String slug, | |
@RequestBody ArticleUpdateRequest request, @AuthenticationPrincipal Long loginId) { | |
public ResponseEntity<ArticleResponse> updateArticle( | |
@PathVariable String slug, | |
@RequestBody ArticleUpdateRequest request, | |
@AuthenticationPrincipal Long loginId) { |
이게 더 깔끔해보이더라고요!
public ArticleUpdateModel toArticleUpdateModel() { | ||
return new ArticleUpdateModel( | ||
Optional.ofNullable(title).map(Title::of).orElse(null), | ||
Optional.ofNullable(description).map(Description::of).orElse(null), | ||
Optional.ofNullable(body).map(Body::of).orElse(null) | ||
); | ||
} |
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.
저도 이 부분에 대해서 고민했는데
Dto | Model |
---|---|
String | VO |
String이 널값이면, VO 내에서 null인지 검증하는 형태로 작성할 것 같아요
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.
지금 이제 마지막 update 구현인데 이거는 조금 더 고민해봐야할 거 같아요.
지금 구조가 마음에 안들긴한데 말씀해주신게 더 좋아보이는거 같긴 하네요 :)
@@ -25,7 +26,7 @@ | |||
@JoinTable(name = "article_tag", | |||
joinColumns = @JoinColumn(name = "article_id"), | |||
inverseJoinColumns = @JoinColumn(name = "tag_id")) | |||
@ManyToMany(cascade = CascadeType.PERSIST) | |||
@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) |
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.
@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | |
@ManyToMany( fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) |
별거 아닐 수 있는데 순서는 중요한 쪽으로 놓는게 좋을 것 같아요
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.
안그래도 순서에 대해서 계속 고민하고 있었는데 확인 감사합니다 :)
@@ -13,7 +13,7 @@ spring: | |||
use_sql_comments: true | |||
hibernate: | |||
ddl-auto: create | |||
open-in-view: false | |||
open-in-view: true |
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.
OSIV!
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: #63
작업 내용
생성/변경 로직
개인 코멘트