-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 회원 설문 도메인 및 API 구현 #32
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
* feat: pkg 디렉토리로 감싸도록 수정 및 API 구현 * refactor: 패키지 조회 무한 스크롤 방식으로 수정 * feat: 상품 이미지 추가 구현 * refactor: 스웨거 설명 변경 * refactor: 반환자 변경
* feat: 장소 도메인 설계 * feat: 장소 생성, 수정 기능 구현 * fix: Jpa 필드명 수정 * fix: 디렉터리명 수정 * feat: 테스트 코드 구현 * feat: pkg 디렉토리로 감싸도록 수정 및 API 구현 * refactor: 패키지 조회 무한 스크롤 방식으로 수정 * feat: 상품 이미지 추가 구현 * refactor: 스웨거 설명 변경 * feat: 패키지 이벤트 추가 * fix: replace -> update로 수정 * fix: location test 메서드명 수정 * refactor: payload 구조로 변경 --------- Co-authored-by: sosow0212 <[email protected]>
sosow0212
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.
작업하신 거에 큰 이견 없습니다~ 수고하셨습니다👍 현재 패키지 구조가 꼬인게 있는 것 같은데 이건 차주에 모든 작업 마치고 한 번에 정리할게요!
| fun findUserSurvey(userId: Long): UserSurveyResponse { | ||
| val survey = userSurveyRepository.findByUserId(userId) | ||
| ?: throw IllegalArgumentException("UserSurvey does not exist.") | ||
|
|
||
| return UserSurveyResponse.from(survey) | ||
| } | ||
|
|
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.
이건 조회용으로 보여서 QueryService로 가는게 좋아보입니다!
현재 커맨드 서비스에서 사용한다면, private fun으로 만들어주세요
| import org.springframework.data.jpa.repository.JpaRepository | ||
|
|
||
| interface UserSurveyJpaRepository: JpaRepository<UserSurvey, Long> { | ||
| fun findByUserId(userId: Long): UserSurvey? |
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.
코틀린 jpa에서는 findByIdOrNull 이라는 확장함수도 제공하는데 한 번 봐보시면 도움 되실 것 같아요~
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.
설문은 회원당 1개만 존재하고, @LoginUser로 사용자를 식별하면 호출부가 단순해져서 조회할 때 surveyId가 아니라 userId로 구현한 상태예요. Repository에서도 findById가 아니라 findByUserId로 Survey를 조회하고 있는데, surveyId를 받아서 조회하는 게 좋을까요?
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.
아아 이해했습니다~ 어차피 user랑 survey는 1:1이니 그대로 두셔도 될 거 같아요 (인덱스만 잘 걸어주세요!)
| @ElementCollection | ||
| @CollectionTable( | ||
| name = "user_survey_places", | ||
| joinColumns = [JoinColumn(name = "user_survey_id")] | ||
| ) | ||
| @Column(name = "place", nullable = false, length = 100) | ||
| val places: List<String> |
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.
사전 위치 기반으로 데이터를 제공해준다면, 해당 정보가 필요할 거 같은데 조회할 때 복잡한 요구사항은 없을 것 같아서 지금 구조도 괜찮아 보입니다! 나중에 위치 데이터를 복잡하게 다룬다면 그때 개선하는 걸로 하시죠!!
📄 작업 내용
설문 기능을 추가했습니다.
🙋🏻 이슈 / 궁금증 / 추가사항
방문 장소를 여러 개 입력받을 수 있게 되어있어서
@ElementCollection으로 별도의 테이블에 저장하도록 구현했는데,단순 저장, 조회만 하는 경우라면 단일 컬럼에 장소를 저장하는 게 나을까요?