-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: 회원 상세 정보 저장 및 조회 구현 #9
Merged
Merged
Changes from all commits
Commits
Show all changes
226 commits
Select commit
Hold shift + click to select a range
7d1e91a
feat: 프로필 속성 정의
devholic22 4117809
feat: 프로필 속성 정의
devholic22 208fd0e
refactor: 프로필 속성 구조 수정
devholic22 0d8e60b
refactor: 프로필 속성 구조 수정
devholic22 226ad3a
fix: 로그인 정보 식별 오류 수정
devholic22 bbd7b66
refactor: 클래스 경로 및 구조 수정
devholic22 4a84e31
feat: Repository 정의
devholic22 5e7cd52
feat: DTO 정의
devholic22 02a0cea
feat: 이벤트 처리 구현
devholic22 f439212
feat: InfoController 작성
devholic22 7b2af53
feat: InfoController 작성
devholic22 9fc8b60
Merge branch 'feat/7' of https://github.com/sosow0212/atwoz into feat/7
devholic22 d01bc01
fix: Hobbies, Styles 저장 오류 수정
devholic22 741d8aa
refactor: 공백 추가
devholic22 b206757
refactor: Hobbies, Styles 엔티티화 해제
devholic22 6fd0553
fix: Option, Profile 중복 저장 오류 해결
devholic22 18123be
refactor: MemberService 공통 축약
devholic22 4e3d4d1
refactor: Member id Column 속성 삭제
devholic22 db4e702
refactor: Member에서 Hobbies, Styles 삭제
devholic22 d7f3f93
refactor: 이벤트 시제 변경
devholic22 5ee2eba
refactor: MemberBody 수정
devholic22 1a7a8ff
refactor: Profile, Option 이벤트 핸들러 이름 변경
devholic22 8481b08
refactor: NullValueException 삭제
devholic22 8cb873b
refactor: 사이즈 0일 시 isEmpty 사용
devholic22 0b7d094
refactor: Repository 인터페이스 위치 수정
devholic22 e615cd4
refactor: Member - Hobby 구조 수정
devholic22 a77c05f
refactor: Member - Style 구조 수정
devholic22 014751a
fix: Option 수정 기능 오류 수정
devholic22 7e29a6d
feat: Position 추가
devholic22 504e59d
feat: 프로필 (Profile) 조회 작성
devholic22 d3b3ea9
feat: 옵션 (Option) 조회 작성
devholic22 a5705eb
refactor: OptionController 위치 수정
devholic22 fb28387
feat: 회원 취미 조회 작성
devholic22 47fa1a0
feat: 회원 스타일 조회 작성
devholic22 f6e5215
refactor: Body 생성 수정
devholic22 07f60d0
refactor: Profile 조회 시 이름 수정
devholic22 fdfb4d2
refactor: 중복 선택 예외처리 추가
devholic22 28e0570
test: HobbyName 테스트 작성
devholic22 1f61cf0
test: StyleName 테스트 작성
devholic22 be7ce4d
test: Gender 테스트 작성
devholic22 d7d79ab
test: BodyTest 작성
devholic22 9f7904d
test: Position 테스트 작성
devholic22 7a63627
test: ProfileJpaRepository 테스트 작성
devholic22 a2ef0d9
test: OptionJpaRepository 테스트 작성
devholic22 d9a5089
test: HobbyJpaRepository 테스트 작성
devholic22 f66f1f4
test: StyleJpaRepository 테스트 작성
devholic22 18db8df
test: HobbyService 테스트 작성
devholic22 e58e6b2
test: StyleService 테스트 작성
devholic22 7e62fb8
test: OptionService 테스트 작성
devholic22 5b70292
test: ProfileService 테스트 작성
devholic22 1e58309
test: OptionServiceTest 수정
devholic22 00da0ba
test: InfoService 테스트 작성
devholic22 ec7cde9
test: HobbyControllerWebMvc 테스트 작성
devholic22 c8c05a7
test: HobbyControllerWebMvc 수정
devholic22 f35e9c6
test: StyleControllerWebMvc 테스트 작성
devholic22 d1c3cb1
test: OptionControllerWebMvc 테스트 작성
devholic22 153bcb1
test: ProfileControllerWebMvc 테스트 작성
devholic22 8e53aef
test: InfoControllerWebMvc 테스트 작성
devholic22 381d8b5
refactor: 예외 핸들러에 추가
devholic22 f0fa2a9
docs: API 문서들에 HTTP request 추가
devholic22 d1a4d0c
refactor: DTO 인자 공백 삭제
devholic22 e0370d7
refactor: HobbyName 검증 메서드 분할
devholic22 5d70f1a
refactor: HobbyRepository final 인자 수정
devholic22 aabc021
refactor: OptionFactory 공백 삭제
devholic22 050ce6c
refactor: InfoController 공백 삭제
devholic22 1cc1470
refactor: HobbyJpaRepository final 인자 수정
devholic22 9e7c033
refactor: 컨트롤러 memberId final 인자 수정
devholic22 4bde570
refactor: Body 나이 계산 수정
devholic22 cb9188d
refactor: Option, Profile 메서드 인자 줄내림
devholic22 8310c83
refactor: 테스트 파일 public 제어자 삭제
devholic22 dd7cd0b
refactor: 서비스 테스트의 MockitoExtension 제거
devholic22 91465b0
refactor: InfoServiceTest 필드 제어자 추가
devholic22 34817bb
refactor: ProfileServiceTest 중복 검증 삭제
devholic22 5ca32b2
refactor: YearManager 패키지 위치 수정
devholic22 9dd50e9
refactor: HobbyName 조회 메서드명 수정
devholic22 c39a9f2
refactor: StyleName 조회 메서드명 수정
devholic22 abeb3ef
refactor: Position BigDecimal 교체
devholic22 b5e945b
refactor: ParseMemberIdFromTokenInterceptor url 수정
devholic22 88777a5
refactor: Option 존재 여부 메서드 성능 개선
devholic22 5194b38
refactor: Profile 존재 여부 메서드 성능 개선
devholic22 cf4c7e6
refactor: HobbyFakeRepository id 저장 수정
devholic22 79c79c5
refactor: StyleFakeRepository id 저장 수정
devholic22 c16341a
refactor: DTO 정적 팩터리 메서드 추가
devholic22 84f3006
refactor: DTO 정적 팩터리 메서드 추가
devholic22 41e30f7
refactor: MockBean 캐싱 처리 적용
devholic22 d6e166e
refactor: InfoService 메서드 분리
devholic22 b460eeb
refactor: MockBean 어노테이션 삭제
devholic22 31209e6
refactor: StyleControllerWebMvcTest 헤더 정보 추가
devholic22 e017194
refactor: ProfileControllerWebMvcTest 헤더 정보 추가
devholic22 b9d475a
refactor: OptionControllerWebMvcTest 헤더 정보 추가
devholic22 67ef079
refactor: InfoControllerWebMvcTest 헤더 정보 추가
devholic22 570f2f4
refactor: HobbyControllerWebMvcTest 헤더 정보 추가
devholic22 dfed61b
refactor: 하위 DTO들의 validation 적용
devholic22 976e410
refactor: OptionService 메서드 분리 해제
devholic22 f39669b
refactor: Hobby 코드 추가
devholic22 4eda5dd
refactor: Style 코드 추가
devholic22 2d84172
refactor: Job enum으로 변경
devholic22 551f0e3
refactor: Hobby 응답 코드로 수정
devholic22 2d961ce
refactor: Style 응답 코드로 수정
devholic22 56354cb
refactor: 값 범위 예외 분할
devholic22 bd9fa81
refactor: info 작성 상태 코드 변경
devholic22 d4fa067
refactor: InfoServiceTest beforeEach 삭제
devholic22 1d733d6
refactor: Factory 정적 클래스화
devholic22 439b19c
refactor: YearManager 생성자로 이동
devholic22 5f8aaa0
refactor: InfoService 메서드명 변경
devholic22 8263a1e
refactor: Hobby, Style 요청 이름 변경
devholic22 8cd2391
refactor: BodyFixture 변수 할당으로 수정
devholic22 3884a88
refactor: 테스트 데이터 Fixture 추가
devholic22 0fcd5f4
refactor: 테스트 데이터 Fixture 적용
devholic22 9864d37
refactor: Info 조회 모델 생성 (Querydsl)
devholic22 e46c0ce
refactor: Profile, Option 저장 값 비교 방식 수정
devholic22 a84e8f9
refactor: Image 삭제
devholic22 e59e03c
refactor: Hobby, HobbyName 이름 변경
devholic22 f532a38
refactor: InfoRepositoryImpl 용어 변경
devholic22 ae46225
refactor: PropertyNotFoundException 삭제
devholic22 24d33b6
refactor: Job 메서드, 예외 이름 수정
devholic22 43e3aca
refactor: Style, StyleName 이름 변경
devholic22 6bbdcb2
refactor: MemberStyle 인자 이름 변경
devholic22 737c4cb
refactor: Hobby, Style 조회 실패 예외 메서드명 변경
devholic22 9ee676d
refactor: InfoRepositoryImpl 용어 변경
devholic22 e5b20de
test: Drink 테스트 작성
devholic22 66ef872
test: Graduate 테스트 작성
devholic22 c483c34
test: Mbti 테스트 작성
devholic22 007cffc
test: Religion 테스트 작성
devholic22 b4c00f6
test: Smoke 테스트 작성
devholic22 869dabf
test: Profile 테스트 작성
devholic22 e3e3967
test: Option 테스트 작성
devholic22 bc7a3fd
refactor: MemberStyleJpaRepositoryTest 이름 수정
devholic22 ba3cc01
refactor: MemberStyleJpaRepositoryTest 변수 수정
devholic22 bcc9e29
refactor: MemberHobbyJpaRepositoryTest 변수 수정
devholic22 d2965cf
refactor: MemberHobbyFakeRepository 변수 수정
devholic22 00929b1
refactor: MemberStyleFakeRepository 변수 수정
devholic22 c3dbae3
refactor: ProfileJpaRepositoryTest ignoringFields 추가
devholic22 6a06503
refactor: OptionJpaRepositoryTest ignoringFields 추가
devholic22 c940570
refactor: Hobby 변수 및 메서드 수정
devholic22 f755d7f
refactor: Style 변수 및 메서드 수정
devholic22 6d99997
refactor: Enumerated 위치 수정
devholic22 3869917
refactor: NoArgsConstructor 위치 수정
devholic22 7e65680
refactor: exists 쿼리 성능 개선 적용
devholic22 bca409a
refactor: 이벤트 RequiredArgsConstructor 통일
devholic22 8582f6e
refactor: OptionEventHandler 공백 추가
devholic22 4a46263
refactor: Location, Position 표현 수정
devholic22 5b4bc02
refactor: ProfileFactory 공백 추가
devholic22 fced5f3
feat: info 수정 요청 DTO 정의
devholic22 8a2b93b
feat: info 수정 요청 이벤트 정의
devholic22 b27b398
feat: 스타일 수정 구현
devholic22 9901c37
refactor: StyleServiceTest 이름 변경
devholic22 0f4ee57
feat: 취미 수정 구현
devholic22 756fd8c
refactor: StyleService 이름 변경
devholic22 6a1d0ea
refactor: MemberHobbyServiceTest then 변수 위치 수정
devholic22 b7f5894
refactor: MemberStyleServiceTest 오타 수정
devholic22 8dfcf4d
feat: Option 수정 구현
devholic22 5cba3d3
feat: InfoService 수정 메서드 작성
devholic22 8f66dae
refactor: Fixture에 SuppressWarnings 추가
devholic22 616c472
refactor: HobbyInvalid 이름 수정
devholic22 f1e6f8f
refactor: DrinkInvalid 이름 수정
devholic22 d69db5c
refactor: 클래스 이름 수정
devholic22 84c2e61
refactor: MemberStyleRepository final 추가
devholic22 57303b2
refactor: PositionTest 인자 수정
devholic22 9c369dc
feat: InfoController 정보 수정 메서드 구현
devholic22 fca4ffb
refactor: StyleInvalid 이름 수정
devholic22 e916d1b
test: InfoServiceTest 정보 수정 테스트
devholic22 a9597b8
docs: InfoController 수정 response field 추가
devholic22 89b38c5
refactor: InfoControllerWebMvcTest Fixture 추가
devholic22 e2bc9bc
test: InfoServiceTest 조회 테스트 작성
devholic22 18b2041
refactor: ProfileServiceTest ignoringFields 추가
devholic22 73107c3
refactor: 인터페이스 인자 final 추가
devholic22 3612110
refactor: OptionFactory 메서드 통일
devholic22 9494c63
feat: ProfileService 수정 메서드 구현
devholic22 af7d92c
fix: ProfileEventHandler 서비스 호출 등록
devholic22 9a4eee7
refactor: OptionFactory request 추상화
devholic22 50612de
refactor: ProfileFactory request 추상화
devholic22 83241e1
fix: OptionRequest 구현체 DTO 기본 생성자 추가
devholic22 77dcc60
refactor: Request private 속성 추가
devholic22 989fffa
refactor: Job 조회 메서드명 수정
devholic22 8495097
refactor: HobbyJpaRepository 이름 수정
devholic22 3f77b04
refactor: Style 검증 코드 분할
devholic22 a961677
refactor: 응답 DTO 공백 추가
devholic22 9db6534
refactor: JpaRepositoryTest ignoringFields 추가
devholic22 2ff647c
fix: Style 검증 예외 수정
devholic22 5804df5
refactor: AllArgsConstructor access 단계 수정
devholic22 ccf0e67
refactor: ProfileServiceTest 예외 검증
devholic22 6e6998a
refactor: OptionServiceTest 예외 검증
devholic22 6bb85db
refactor: InfoService MockBeanInjection 이동
devholic22 cef5341
refactor: MemberRepository 의존 삭제
devholic22 b53a6d1
refactor: DTO 공백 삭제
devholic22 90d982f
refactor: Request DTO 인터페이스 삭제
devholic22 4c393ed
refactor: Q파일 static import 처리
devholic22 517401b
refactor: 테스트 용어 구분 추가
devholic22 64049be
test: InfoController 인수 테스트 작성
devholic22 35d1ec1
refactor: 테스트 메서드 수정
sosow0212 e1db46e
refactor: Profile, Option, MemberHobby, MemberStyle Fixture 작성
devholic22 cfff6cc
refactor: 인수 테스트 given Fixture 이용
devholic22 6e8bd28
refactor: 테스트 요청 Fixture 구조 수정
devholic22 1e41618
refactor: Querydsl 구현체 분리
devholic22 1efb1f6
refactor: MemberHobby, MemberStyle 삭제 쿼리 개선
devholic22 654235e
test: InfoController 인수 테스트 추가 작성
devholic22 d6eacb3
refactor: InfoSearchResponse 예외 이동
devholic22 c6b7147
refactor: InfoServiceTest 이벤트 mock 처리
devholic22 34f4d3f
refactor: 수정 테스트 시 리포지터리를 이용하도록 수정
devholic22 9b12d09
refactor: OptionFactory 제거
devholic22 6ad6749
refactor: Profile, Option 업데이트 방식 변경
devholic22 920fad8
refactor: Option 내부 DTO 생성
devholic22 3cf519b
refactor: ProfileFactory 삭제
devholic22 c9aae30
refactor: BodySearchResponseFixture 클래스로 복구
devholic22 087c304
refactor: Profile, Option 조인 조회 방식으로 수정
devholic22 dff9f00
refactor: 이벤트 패키지 수정
devholic22 b4777a8
refactor: DTO 패키지 수정
devholic22 9be88b7
refactor: 이벤트 패키지 위치 조정
devholic22 a0a1eff
refactor: 응답 DTO 위치 조정
devholic22 32a3fe7
refactor: Fixture 구조 수정
devholic22 0c8d4cf
refactor: InnerProfile DTO 위치 수정
devholic22 1308dc4
refactor: 서비스 테스트 패키지 수정
devholic22 10e2808
test: 취미 서비스 단계의 예외 검증 추가
devholic22 40e8796
test: 스타일 서비스 단계의 예외 검증 추가
devholic22 d64c1c2
refactor: 도메인 테스트 패키지 수정
devholic22 7fad512
refactor: JPA 리포지터리 메서드들이 명시되도록 수정
devholic22 0217c19
fix: findAll 메서드 재정의 삭제
devholic22 b5cb745
refactor: Fixture static import 추가
devholic22 a5cde12
test: InfoQueryRepository 테스트 추가
devholic22 1b23328
refactor: Job 예외 패키지 수정
devholic22 ded8bd8
refactor: Option, Body 정적 팩터리 메서드 수정
devholic22 b0433e0
refactor: InnerOptionUpdateRequest 공백 추가
devholic22 26513b3
refactor: Profile updateContents 삭제
devholic22 972ede0
refactor: InnerProfileUpdateRequest Fixture 추가
devholic22 7201923
refactor: InfoService 메서드 체이닝 최소화
devholic22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
:toc: left | ||
:source-highlighter: highlightjs | ||
:sectlinks: | ||
:toclevels: 2 | ||
:sectlinks: | ||
:sectnums: | ||
|
||
== Info | ||
|
||
=== 회원 정보 작성 | ||
|
||
==== 요청 | ||
include::{snippets}/info-controller-web-mvc-test/write_info/http-request.adoc[] | ||
include::{snippets}/info-controller-web-mvc-test/write_info/request-headers.adoc[] | ||
include::{snippets}/info-controller-web-mvc-test/write_info/request-fields.adoc[] | ||
|
||
==== 응답 | ||
include::{snippets}/info-controller-web-mvc-test/write_info/http-response.adoc[] | ||
|
||
=== 회원 정보 수정 | ||
|
||
==== 요청 | ||
include::{snippets}/info-controller-web-mvc-test/update_info/http-request.adoc[] | ||
include::{snippets}/info-controller-web-mvc-test/update_info/request-headers.adoc[] | ||
include::{snippets}/info-controller-web-mvc-test/update_info/request-fields.adoc[] | ||
|
||
==== 응답 | ||
include::{snippets}/info-controller-web-mvc-test/update_info/http-response.adoc[] | ||
|
||
=== 회원 정보 조회 | ||
|
||
==== 요청 | ||
include::{snippets}/info-controller-web-mvc-test/search_info/http-request.adoc[] | ||
include::{snippets}/info-controller-web-mvc-test/search_info/request-headers.adoc[] | ||
==== 응답 | ||
include::{snippets}/info-controller-web-mvc-test/search_info/http-response.adoc[] | ||
include::{snippets}/info-controller-web-mvc-test/search_info/response-fields.adoc[] |
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
...pplication/event/ValidatedLoginEvent.java → ...ation/auth/event/ValidatedLoginEvent.java
This file contains 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
85 changes: 85 additions & 0 deletions
85
src/main/java/com/atwoz/member/application/info/InfoService.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.atwoz.member.application.info; | ||
|
||
import com.atwoz.global.event.Events; | ||
import com.atwoz.member.application.info.hobby.event.HobbyUpdatedEvent; | ||
import com.atwoz.member.application.info.hobby.event.HobbyWroteEvent; | ||
import com.atwoz.member.application.info.option.event.OptionUpdatedEvent; | ||
import com.atwoz.member.application.info.option.event.OptionWroteEvent; | ||
import com.atwoz.member.application.info.profile.event.ProfileUpdatedEvent; | ||
import com.atwoz.member.application.info.profile.event.ProfileWroteEvent; | ||
import com.atwoz.member.application.info.style.event.StyleUpdatedEvent; | ||
import com.atwoz.member.application.info.style.event.StyleWroteEvent; | ||
import com.atwoz.member.application.info.hobby.dto.HobbyUpdateRequest; | ||
import com.atwoz.member.application.info.hobby.dto.HobbyWriteRequest; | ||
import com.atwoz.member.application.info.dto.InfoUpdateRequest; | ||
import com.atwoz.member.application.info.dto.InfoWriteRequest; | ||
import com.atwoz.member.application.info.style.dto.StyleUpdateRequest; | ||
import com.atwoz.member.application.info.style.dto.StyleWriteRequest; | ||
import com.atwoz.member.domain.info.InfoRepository; | ||
import com.atwoz.member.exception.exceptions.info.InfoNotFoundException; | ||
import com.atwoz.member.infrastructure.info.dto.InfoSearchResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
@Service | ||
public class InfoService { | ||
|
||
private final InfoRepository infoRepository; | ||
|
||
@Transactional | ||
public void writeInfo(final Long memberId, final InfoWriteRequest request) { | ||
List<String> hobbyCodes = extractHobbyNamesFromInfoWriteRequest(request.hobbies()); | ||
List<String> styleCodes = extractStyleNamesFromInfoWriteRequest(request.styles()); | ||
|
||
Events.raise(new ProfileWroteEvent(memberId, request.profile())); | ||
Events.raise(new OptionWroteEvent(memberId, request.option())); | ||
|
||
Events.raise(new HobbyWroteEvent(memberId, hobbyCodes)); | ||
Events.raise(new StyleWroteEvent(memberId, styleCodes)); | ||
} | ||
|
||
private List<String> extractHobbyNamesFromInfoWriteRequest(final List<HobbyWriteRequest> hobbies) { | ||
return hobbies.stream() | ||
.map(HobbyWriteRequest::hobby) | ||
.toList(); | ||
} | ||
|
||
private List<String> extractStyleNamesFromInfoWriteRequest(final List<StyleWriteRequest> styles) { | ||
return styles.stream() | ||
.map(StyleWriteRequest::style) | ||
.toList(); | ||
} | ||
|
||
@Transactional | ||
public void updateInfo(final Long memberId, final InfoUpdateRequest request) { | ||
List<String> hobbyCodes = extractHobbyNamesFromInfoUpdateRequest(request.hobbies()); | ||
List<String> styleCodes = extractStyleNamesFromInfoUpdateRequest(request.styles()); | ||
|
||
Events.raise(new ProfileUpdatedEvent(memberId, request.profile())); | ||
Events.raise(new OptionUpdatedEvent(memberId, request.option())); | ||
|
||
Events.raise(new HobbyUpdatedEvent(memberId, hobbyCodes)); | ||
Events.raise(new StyleUpdatedEvent(memberId, styleCodes)); | ||
} | ||
|
||
private List<String> extractHobbyNamesFromInfoUpdateRequest(final List<HobbyUpdateRequest> hobbies) { | ||
return hobbies.stream() | ||
.map(HobbyUpdateRequest::hobby) | ||
.toList(); | ||
} | ||
|
||
private List<String> extractStyleNamesFromInfoUpdateRequest(final List<StyleUpdateRequest> styles) { | ||
return styles.stream() | ||
.map(StyleUpdateRequest::style) | ||
.toList(); | ||
} | ||
|
||
public InfoSearchResponse findInfo(final Long memberId) { | ||
return infoRepository.findByMemberId(memberId) | ||
.orElseThrow(InfoNotFoundException::new); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/atwoz/member/application/info/dto/InfoUpdateRequest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.atwoz.member.application.info.dto; | ||
|
||
import com.atwoz.member.application.info.hobby.dto.HobbyUpdateRequest; | ||
import com.atwoz.member.application.info.option.dto.OptionUpdateRequest; | ||
import com.atwoz.member.application.info.profile.dto.ProfileUpdateRequest; | ||
import com.atwoz.member.application.info.style.dto.StyleUpdateRequest; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
public record InfoUpdateRequest( | ||
@Valid | ||
@NotNull(message = "profile 요청이 있어야 합니다.") | ||
ProfileUpdateRequest profile, | ||
|
||
@Valid | ||
@NotNull(message = "option 요청이 있어야 합니다.") | ||
OptionUpdateRequest option, | ||
|
||
@Valid | ||
@NotNull(message = "취미 요청이 있어야 합니다.") | ||
List<HobbyUpdateRequest> hobbies, | ||
|
||
@Valid | ||
@NotNull(message = "스타일 요청이 있어야 합니다.") | ||
List<StyleUpdateRequest> styles | ||
) { | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/atwoz/member/application/info/dto/InfoWriteRequest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.atwoz.member.application.info.dto; | ||
|
||
import com.atwoz.member.application.info.hobby.dto.HobbyWriteRequest; | ||
import com.atwoz.member.application.info.option.dto.OptionWriteRequest; | ||
import com.atwoz.member.application.info.profile.dto.ProfileWriteRequest; | ||
import com.atwoz.member.application.info.style.dto.StyleWriteRequest; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
public record InfoWriteRequest( | ||
@Valid | ||
@NotNull(message = "profile 요청이 있어야 합니다.") | ||
ProfileWriteRequest profile, | ||
|
||
@Valid | ||
@NotNull(message = "option 요청이 있어야 합니다.") | ||
OptionWriteRequest option, | ||
|
||
@Valid | ||
@NotNull(message = "취미 요청이 있어야 합니다.") | ||
List<HobbyWriteRequest> hobbies, | ||
|
||
@Valid | ||
@NotNull(message = "스타일 요청이 있어야 합니다.") | ||
List<StyleWriteRequest> styles | ||
) { | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/atwoz/member/application/info/hobby/HobbyEventHandler.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.atwoz.member.application.info.hobby; | ||
|
||
import com.atwoz.member.application.info.hobby.event.HobbyUpdatedEvent; | ||
import com.atwoz.member.application.info.hobby.event.HobbyWroteEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class HobbyEventHandler { | ||
|
||
private final MemberHobbyService memberHobbyService; | ||
|
||
@EventListener | ||
public void writeHobbies(final HobbyWroteEvent event) { | ||
Long memberId = event.getMemberId(); | ||
List<String> hobbyCodes = event.getHobbyCodes(); | ||
|
||
memberHobbyService.saveMemberHobbies(memberId, hobbyCodes); | ||
} | ||
|
||
@EventListener | ||
public void updateHobbies(final HobbyUpdatedEvent event) { | ||
Long memberId = event.getMemberId(); | ||
List<String> hobbyCodes = event.getHobbyCodes(); | ||
|
||
memberHobbyService.updateMemberHobbies(memberId, hobbyCodes); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/atwoz/member/application/info/hobby/MemberHobbyService.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.atwoz.member.application.info.hobby; | ||
|
||
import com.atwoz.member.domain.info.hobby.Hobby; | ||
import com.atwoz.member.domain.info.hobby.MemberHobby; | ||
import com.atwoz.member.domain.info.hobby.MemberHobbyRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
@Service | ||
public class MemberHobbyService { | ||
|
||
private final MemberHobbyRepository memberHobbyRepository; | ||
|
||
@Transactional | ||
public void saveMemberHobbies(final Long memberId, final List<String> hobbyCodes) { | ||
saveMemberHobbiesByHobbyCodes(memberId, hobbyCodes); | ||
} | ||
|
||
private void saveMemberHobbiesByHobbyCodes(final Long memberId, final List<String> hobbyCodes) { | ||
List<MemberHobby> memberHobbies = Hobby.findAllByCodes(hobbyCodes) | ||
.stream() | ||
.map(hobby -> new MemberHobby(memberId, hobby)) | ||
.toList(); | ||
|
||
memberHobbyRepository.saveAll(memberHobbies); | ||
} | ||
|
||
@Transactional | ||
public void updateMemberHobbies(final Long memberId, final List<String> hobbyCodes) { | ||
memberHobbyRepository.deleteHobbiesByMemberId(memberId); | ||
|
||
saveMemberHobbiesByHobbyCodes(memberId, hobbyCodes); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/atwoz/member/application/info/hobby/dto/HobbyUpdateRequest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.atwoz.member.application.info.hobby.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record HobbyUpdateRequest( | ||
@NotBlank(message = "취미가 작성되어야 합니다.") | ||
String hobby | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/atwoz/member/application/info/hobby/dto/HobbyWriteRequest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.atwoz.member.application.info.hobby.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record HobbyWriteRequest( | ||
@NotBlank(message = "취미가 작성되어야 합니다.") | ||
String hobby | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/atwoz/member/application/info/hobby/event/HobbyUpdatedEvent.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.atwoz.member.application.info.hobby.event; | ||
|
||
import com.atwoz.global.event.Event; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import java.util.List; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class HobbyUpdatedEvent extends Event { | ||
|
||
private final Long memberId; | ||
private final List<String> hobbyCodes; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/atwoz/member/application/info/hobby/event/HobbyWroteEvent.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.atwoz.member.application.info.hobby.event; | ||
|
||
import com.atwoz.global.event.Event; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import java.util.List; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class HobbyWroteEvent extends Event { | ||
|
||
private final Long memberId; | ||
private final List<String> hobbyCodes; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/atwoz/member/application/info/option/OptionEventHandler.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.atwoz.member.application.info.option; | ||
|
||
import com.atwoz.member.application.info.option.event.OptionUpdatedEvent; | ||
import com.atwoz.member.application.info.option.event.OptionWroteEvent; | ||
import com.atwoz.member.application.info.option.dto.OptionUpdateRequest; | ||
import com.atwoz.member.application.info.option.dto.OptionWriteRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class OptionEventHandler { | ||
|
||
private final OptionService optionService; | ||
|
||
@EventListener | ||
public void writeOption(final OptionWroteEvent event) { | ||
Long memberId = event.getMemberId(); | ||
OptionWriteRequest request = event.getRequest(); | ||
|
||
optionService.writeOption(memberId, request); | ||
} | ||
|
||
@EventListener | ||
public void updateOption(final OptionUpdatedEvent event) { | ||
Long memberId = event.getMemberId(); | ||
OptionUpdateRequest request = event.getRequest(); | ||
|
||
optionService.updateOption(memberId, request); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
이것과 관련해서는 고민점이 있습니다.
회원의 취미/스타일 갯수
>새로 들어온 (수정할) 취미/스타일 갯수
회원의 취미/스타일 갯수
=새로 들어온 (수정할) 취미/스타일 갯수
(이 때는 말씀하신 변경 감지를 이끌어낼 수 있을 듯 합니다.)회원의 취미/스타일 갯수
<새로 들어온 (수정할) 취미/스타일 갯수
updateMemberHobbies
를 할 때 작성했던deleteHobbiesByMemberId
메서드가 저장되었던취미 갯수만큼 각각 delete
쿼리가 일어났던 문제를@Query("delete from MemberHobby mh where mh.memberId = :memberId")
로 한 번에 삭제하도록 수정했는데, 이런 방식으로 이끌어나가도 될 지 여쭤드립니다..!