Conversation
| private String content; | ||
|
|
||
| private int commentCount; | ||
|
|
Author
There was a problem hiding this comment.
Dto에 넣으니까 파라미터로 입력을 받지 않아서 null로 반환하길래 빼긴 했는데
엔티티에서 Dto로 변환할때 setPostedAt을 하는 방법도 있었군,,
|
|
||
| List<Post> findAllByOrderByPostedAtDesc(); | ||
|
|
||
| List<Post> findAllByUserId(Long userId); |
There was a problem hiding this comment.
오 나는 Jpa가 이렇게 똑똑한 줄 몰랐네
JPA에서는 경로를 명확히 지정하는 게 안전하지만, 지금처럼 연관 관계가 명확하게 설정되어 있다면 findAllByUsername처럼 짧은 메서드명으로도 작동할 수 있다. 하지만 현재 돌아가고 있으면 괜찮지만, 다른 팀원이나 미래의 개발자가 코드를 이해하기 쉽게 명시적으로 작성하는 것이 권장된다.
나는 findAllByUse_Username으로 쿼리 날리려고 메서드명 작성했는데 찾아보니까 연관 관계가 매핑되어 있으면 줄여써도 가능하구낭
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/posts") |
There was a problem hiding this comment.
@RequestMapping("/posts/comments")
이렇게 써도 될 듯
(댓글을 한 개라도 더 달려는 노력..)
Author
There was a problem hiding this comment.
아하 엔드포인트 그냥 받아적다 보니 똑같다는걸 인지를 못했네..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.