[feat] 저장한 책 또는 참여 중 모임의 책 조회 api 구현 및 패키지 정리#166
Merged
Conversation
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.
#️⃣ 연관된 이슈
📝 작업 내용
저장한 책 또는 참여 중 모임의 책 조회 api 구현
책 저장 상태 변경 로직 수정
회의에서 말했던 것처럼 SavedBooks라는 일급 컬렉션을 제거하고 existsBy를 통해 저장 검증을 하도록 했습니다. 이때 validate는 도메인 로직보다 서비스 로직에 가까운 것 같아. 서비스 로직에 메서드를 정의했습니다. (Book이라는 도메인이 저장 여부 상태를 담고있는 것은 아니기 때문)
Optional 반환을 통한 try-catch 제거
Optional 반환을 하는 findByIsbn 메서드를 통해 기존 서비스 로직에서 try catch를 하는 로직들을 모두 리팩토링하였습니다.
Saved 패키지 제거
기존 SavedBook과 SavedFeed는 각각 Book과 Feed에 종속되는 엔티티라고 판단되어 Book과 Feed 패키지 하위로 이동시켰습니다. 이에 따라 관련 저장 및 조회 로직도 이동했습니다. (Feed의 adapter가 조금 무거워지는 느낌은 드는데 추후에 Content 테이블을 제거하고 리팩토링하면 쿼리가 더 간단해질 것 같다고 생각합니다!)
📸 스크린샷
💬 리뷰 요구사항
이번 api에서는 페이징 처리가 따로 필요 없어 Book도메인을 그대로 사용했습니다. 이에 따라서 서비스 로직에서는 port.dto에 정의되어 있는 BookInfo의 리스트를 반환하고 컨트롤러 계층에서 Response를 생성하는 책임을 갖도록 했습니다.
BookInfo는 책에 대한 정보를 담고 있는 dto이기 때문에 현재 BookSearchListResponse의 inner class로 사용되고 있는 BookDto를 대체할 수 있을 것 같습니다. (책 검색은 페이징 변수를 다 제거해도 될 것 같다고 생각,, <- 기획적으로)
추가적으로, 구현하면서 들었던 리팩토링에 대한 제안은 노션 -> 서버 리팩토링 회의 밑에 적어두었으니 한번씩 확인부탁드립니다!!
📌 PR 진행 시 이러한 점들을 참고해 주세요
Summary by CodeRabbit
신규 기능
/books/selectable-listAPI가 추가되었습니다.버그 수정
리팩터 및 구조 개선
테스트
문서화