-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 커뮤니티, 지원, 성적 관련 api 수정 #196
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
Conversation
- communities -> boards
- communities/{code}/posts -> posts
Gyuhyeok99
left a comment
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.
고생하셨습니다! 지난번 #171 보면서도 영속성 컨텍스트 관련 이슈가 발생할 위험이 있겠다 생각했었는데 이렇게 발생했네요 🥲
그때부터 고민해봤는데 지금 구현하신 것처럼 siteUserRepository.findById를 이용해서 siteUser를 영속 상태로 관리하는 게 가장 직관적으로 JPA의 변경 감지를 확실하게 보장할 수 있다고 생각했어요.
그래서 저는 말씀하신 siteUser를 영속 상태로 만들 수 있도록 컨트롤러에서 siteUserId 를 넘겨주는 게 제일 좋은 거 같습니다.
- gpa 와 siteUser 사이의 양방향을 끊을 것인지 생각해봐야한다.
그리고 혹시 이 문제가 gpa 와 siteUser 사이의 양방향/단방향이 영속성 문제랑 어떤 관련이 있는지 알려주실 수 있나요??
| @GetMapping("/{code}") | ||
| public ResponseEntity<?> findPostsByCodeAndCategory( | ||
| @PathVariable(value = "code") String code, | ||
| @RequestParam(value = "category", defaultValue = "전체") String category) { |
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.
이건 게시글 리스트를 조회하는 것이길래 제가 지난번에 post쪽으로 옮겼던 것인데 boards가 더 적절한가요?
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.
저렇게 바꾸게 된 맥락을 말씀드리자면!
원래 특정 게시판의 게시글 목록 조회가 /communities/{code}였었어요.
그런데 uri 회의에서 communities 였던걸 boards 로 바꾸기로 해서 /boards/{code} 로 바꾼거예요.
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.
아 기억났습니다! ㅎㅎ.. 깜빡했네요
| private final S3Service s3Service; | ||
| private final RedisService redisService; | ||
| private final RedisUtils redisUtils; | ||
| private final SiteUserRepository siteUserRepository; |
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.
늘 신경써본적 없는 부분이긴 한데 주입 순서 컨벤션을 정해보는 건 어떻게 생각하시나요? 예를들어 주요 도메인 레포지토리 -> 연관된 도메인 레포지토리 -> 서비스 -> 유틸 이런 식으로요
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.
좋은 생각입니다!
이 컨벤션은 따로 정해봐요~ 😊
네 저도 그게 좋다 생각해요.
지금 DB만 생각하면 gpa 가 site_user_id 를 fk 로 가지고 있어요. 그런데 컨트롤러에서 영속 상태가 아닌 (정확히는 준영속 상태의) siteUser 엔티티를 서비스에 내려주니 레이지 로딩이 동작하지 않는 것입니다. |
|
아 그러네요 이해했습니다! 꼭 필요한 곳에만 양방향을 걸어두는 게 좋긴하겠네요. 그래도 양방향이 필요한 곳은 있을테니 컨트롤러에서 siteUserId 를 넘겨주는 게 제일 좋긴 하겠네요 🥹 |
Gyuhyeok99
left a comment
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.
고생하셨습니다!
wibaek
left a comment
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
프론트도 바로 반영 될 수 있게 작업 완료되었습니다.
관련 이슈
작업 내용
회의에 나온 내용들을 반영했습니다😊
특이 사항
URI 복수형 사용
/communites/**에서/boards/**로 변경/application/**에서/applications/**로 변경/score/languageTest/**에서scores/language-tests/**로 변경/score/gpa/**에서/scores/gpas/**로 변경request, response 변경
리뷰 요구사항 (선택)
❗️조금 치명적인 이슈가 있습니다🥲❗️
컨트롤러에서 SiteUser 를 인자로 받기 이전에는,
서비스 코드에서 직접 SiteUser 를 조회해와서, 다른 비지니스 로직들과 동일한 영속성 컨텍스트에 적재되었습니다.
그래서 Lazy Loading 을 사용할 수 있었어요.
하지만 지금은 컨트롤러에서 SiteUser를 가져오기 때문에,
서비스 코드에서 이 SiteUser 는 영속 상태가 아니라 Lazy Loading이 적용되지 않습니다.
이 PR에서는 가장 간편한 해결방법으로 해결하긴 했는데, 추가로 논의가 필요할 것 같습니다.
이건 오늘 회의 끝나고 이야기해봐도 좋을 것 같습니다.
❗️api 변경 사항❗️
https://github.com/solid-connection/api-docs/pull/5