From c4c007f060435449b55cdd5a2e3068d3d263a3ed Mon Sep 17 00:00:00 2001 From: eom-tae-in <101633465+eom-tae-in@users.noreply.github.com> Date: Thu, 2 May 2024 22:30:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=ED=95=9C=EB=8B=A4=20(#27)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: memberController uri 변경 및 조회 메서드 추가 * refactor: MemberHobbies 수정 - EqualsAndHashCode 제거 - 임베디드 -> 엔티티로 타입변경 - 값타입 컬렉션 필드 일대다 관계로 변경(값타입 엔티티로 승격) * refactor: MemberStyles 수정 - EqualsAndHashCode 제거 - 임베디드 -> 엔티티로 타입변경 - 값타입 컬렉션 필드 일대다 관계로 변경(값타입 엔티티로 승격) * feat: 조회 결과를 반환할 dto 추가 - MemberResponse - MemberProfileResponse - HobbiesResponse - StylesResponse * refactor: Profile 변경 - MemberHobbies 필드 타입 변경(임베디드 -> 엔티티) - MemberStyles 필드 타입 변경(임베디드 -> 엔티티) * feat: MemberHobby, MemberStyle 추가 - Hobby(Enum), Style(Enum)을 엔티티로 승격시키기 위해 MemberHobby, MemberStyle 추가 * feat: 조회 기능 추가 * move: 파일 경로 변경 * refactor: 조회와 쓰기를 분리 작업 진행 * test: HobbiesResponseFixture 생성 * test: MemberHobbiesTest 생성 * test: MemberProfileDtoFixture 생성 * test: MemberProfileResponseFixture 생성 * test: MemberQueryRepositoryTest 생성 * test: MemberQueryServiceTest 생성 * test: MemberResponseFixture 생성 * test: MemberStylesTest 생성 * test: StylesResponseFixture 생성 * test: 파일 경로 변경 및 프로덕션 코드 변경으로 인한 수정 * test: 불필요한 코드 제거 * docs: asciiDoc 문서 수정 * refactor: MemberHobies의 @AllArgsConstuctor 접근 제어자 변경 PUBLIC -> PRIVATE * refactor: 회원 조회 메서드 네이밍 변경 findMemberWithProfile -> findMemberWithId * test: 메서드명 오타 수정 * remove: 불필요한 클래스 제거 MemberNicknameRequest * refactor: 메서드 로직 수정 * refactor: 메서드 매개변수 변경 * test: 프로덕션 코드 변경으로 인한 테스트 수정 --- src/docs/asciidoc/auth.adoc | 2 +- src/docs/asciidoc/member.adoc | 21 ++-- .../member/MemberQueryService.java | 26 +++++ .../application/member/MemberService.java | 18 +-- .../member/dto/MemberNicknameRequest.java | 9 -- .../domain/member/MemberRepository.java | 3 + .../profile/{vo => }/MemberHobbies.java | 56 ++++----- .../domain/member/profile/MemberHobby.java | 44 +++++++ .../domain/member/profile/MemberStyle.java | 44 +++++++ .../member/profile/{vo => }/MemberStyles.java | 56 ++++----- .../member/domain/member/profile/Profile.java | 19 ++-- .../member/MemberQueryRepository.java | 107 ++++++++++++++++++ .../member/MemberRepositoryImpl.java | 7 ++ .../member/dto/HobbiesResponse.java | 15 +++ .../member/dto/MemberProfileResponse.java | 58 ++++++++++ .../member/dto/MemberResponse.java | 8 ++ .../member/dto/StylesResponse.java | 15 +++ .../member/ui/member/MemberController.java | 28 +++-- .../com/atwoz/helper/MockBeanInjection.java | 4 + .../member/MemberQueryServiceTest.java | 77 +++++++++++++ .../application/member/MemberServiceTest.java | 26 ----- .../domain/profile/MemberHobbiesTest.java | 74 ++++++++++++ .../domain/profile/MemberStylesTest.java | 74 ++++++++++++ .../member/domain/profile/ProfileTest.java | 14 ++- .../profile/physical/{ => vo}/GenderTest.java | 2 +- .../domain/profile/{ => vo}/DrinkTest.java | 2 +- .../domain/profile/{ => vo}/GraduateTest.java | 2 +- .../domain/profile/{ => vo}/HobbyTest.java | 2 +- .../domain/profile/{ => vo}/JobTest.java | 2 +- .../domain/profile/{ => vo}/MbtiTest.java | 2 +- .../domain/profile/{ => vo}/PositionTest.java | 2 +- .../domain/profile/{ => vo}/ReligionTest.java | 2 +- .../domain/profile/{ => vo}/SmokeTest.java | 2 +- .../domain/profile/{ => vo}/StyleTest.java | 2 +- .../fixture/HobbiesResponseFixture.java | 25 ++++ .../atwoz/member/fixture/MemberFixture.java | 13 ++- .../fixture/MemberProfileDtoFixture.java | 28 +++++ .../fixture/MemberProfileInfoFixture.java | 1 + .../fixture/MemberProfileResponseFixture.java | 41 +++++++ .../member/fixture/MemberResponseFixture.java | 16 +++ .../member/fixture/OAuthProviderFixture.java | 1 + .../member/fixture/StylesResponseFixture.java | 25 ++++ .../member/MemberFakeRepository.java | 22 +++- .../member/MemberQueryRepositoryTest.java | 50 ++++++++ .../MemberControllerAcceptanceFixture.java | 47 ++++---- .../MemberControllerAcceptanceTest.java | 31 +++-- .../ui/member/MemberControllerWebMvcTest.java | 89 +++++++++------ ...erMissionsControllerAcceptanceFixture.java | 1 - 48 files changed, 1009 insertions(+), 206 deletions(-) create mode 100644 src/main/java/com/atwoz/member/application/member/MemberQueryService.java delete mode 100644 src/main/java/com/atwoz/member/application/member/dto/MemberNicknameRequest.java rename src/main/java/com/atwoz/member/domain/member/profile/{vo => }/MemberHobbies.java (57%) create mode 100644 src/main/java/com/atwoz/member/domain/member/profile/MemberHobby.java create mode 100644 src/main/java/com/atwoz/member/domain/member/profile/MemberStyle.java rename src/main/java/com/atwoz/member/domain/member/profile/{vo => }/MemberStyles.java (57%) create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/MemberQueryRepository.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/dto/HobbiesResponse.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/dto/MemberProfileResponse.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/dto/MemberResponse.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/dto/StylesResponse.java create mode 100644 src/test/java/com/atwoz/member/application/member/MemberQueryServiceTest.java create mode 100644 src/test/java/com/atwoz/member/domain/profile/MemberHobbiesTest.java create mode 100644 src/test/java/com/atwoz/member/domain/profile/MemberStylesTest.java rename src/test/java/com/atwoz/member/domain/profile/physical/{ => vo}/GenderTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/DrinkTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/GraduateTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/HobbyTest.java (97%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/JobTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/MbtiTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/PositionTest.java (98%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/ReligionTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/SmokeTest.java (96%) rename src/test/java/com/atwoz/member/domain/profile/{ => vo}/StyleTest.java (97%) create mode 100644 src/test/java/com/atwoz/member/fixture/HobbiesResponseFixture.java create mode 100644 src/test/java/com/atwoz/member/fixture/MemberProfileDtoFixture.java create mode 100644 src/test/java/com/atwoz/member/fixture/MemberProfileResponseFixture.java create mode 100644 src/test/java/com/atwoz/member/fixture/MemberResponseFixture.java create mode 100644 src/test/java/com/atwoz/member/fixture/StylesResponseFixture.java create mode 100644 src/test/java/com/atwoz/member/infrastructure/member/MemberQueryRepositoryTest.java diff --git a/src/docs/asciidoc/auth.adoc b/src/docs/asciidoc/auth.adoc index cdd8024b..6835b9ac 100644 --- a/src/docs/asciidoc/auth.adoc +++ b/src/docs/asciidoc/auth.adoc @@ -5,7 +5,7 @@ :sectlinks: :sectnums: -== Member +== Auth === 로그인 diff --git a/src/docs/asciidoc/member.adoc b/src/docs/asciidoc/member.adoc index a1bcf005..580247dd 100644 --- a/src/docs/asciidoc/member.adoc +++ b/src/docs/asciidoc/member.adoc @@ -5,7 +5,7 @@ :sectlinks: :sectnums: -== Info +== Member === 닉네임 중복 확인 (GET /api/members/nickname/existence) @@ -18,11 +18,10 @@ include::{snippets}/member-controller-web-mvc-test/닉네임_중복_확인/http- include::{snippets}/member-controller-web-mvc-test/닉네임_중복_확인/http-response.adoc[] -=== 회원 정보 초기화 (POST /api/members/{memberId}) +=== 회원 정보 초기화 (POST /api/members) ==== 요청 include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/request-headers.adoc[] -include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/path-parameters.adoc[] include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/request-fields.adoc[] include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/http-request.adoc[] @@ -30,11 +29,20 @@ include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/http- include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/http-response.adoc[] -=== 회원 정보 수정 (PATCH /api/members/{memberId}) +=== 회원 정보 조회(GET /api/members) +==== 요청 +include::{snippets}/member-controller-web-mvc-test/회원_정보_조회/request-headers.adoc[] +include::{snippets}/member-controller-web-mvc-test/회원_정보_조회/http-request.adoc[] + +==== 응답 +include::{snippets}/member-controller-web-mvc-test/회원_정보_조회/response-body.adoc[] +include::{snippets}/member-controller-web-mvc-test/회원_정보_조회/http-response.adoc[] + + +=== 회원 정보 수정 (PATCH /api/members) ==== 요청 include::{snippets}/member-controller-web-mvc-test/회원_정보_수정/request-headers.adoc[] -include::{snippets}/member-controller-web-mvc-test/회원_정보_수정/path-parameters.adoc[] include::{snippets}/member-controller-web-mvc-test/회원_정보_수정/request-fields.adoc[] include::{snippets}/member-controller-web-mvc-test/회원_정보_수정/http-request.adoc[] @@ -42,11 +50,10 @@ include::{snippets}/member-controller-web-mvc-test/회원_정보_수정/http-req include::{snippets}/member-controller-web-mvc-test/회원_정보_수정/http-response.adoc[] -=== 회원 삭제 (DELETE /api/members/{memberId}) +=== 회원 삭제 (DELETE /api/members) ==== 요청 include::{snippets}/member-controller-web-mvc-test/회원_삭제/request-headers.adoc[] -include::{snippets}/member-controller-web-mvc-test/회원_삭제/path-parameters.adoc[] include::{snippets}/member-controller-web-mvc-test/회원_삭제/http-request.adoc[] ==== 응답 diff --git a/src/main/java/com/atwoz/member/application/member/MemberQueryService.java b/src/main/java/com/atwoz/member/application/member/MemberQueryService.java new file mode 100644 index 00000000..23e16b2f --- /dev/null +++ b/src/main/java/com/atwoz/member/application/member/MemberQueryService.java @@ -0,0 +1,26 @@ +package com.atwoz.member.application.member; + +import com.atwoz.member.domain.member.MemberRepository; +import com.atwoz.member.exception.exceptions.member.MemberNicknameAlreadyExistedException; +import com.atwoz.member.infrastructure.member.dto.MemberResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +@Transactional(readOnly = true) +@Service +public class MemberQueryService { + + private final MemberRepository memberRepository; + + public void checkMemberExists(final String nickname) { + if (memberRepository.existsByNickname(nickname)) { + throw new MemberNicknameAlreadyExistedException(); + } + } + + public MemberResponse findMember(final Long memberId) { + return memberRepository.findMemberWithId(memberId); + } +} diff --git a/src/main/java/com/atwoz/member/application/member/MemberService.java b/src/main/java/com/atwoz/member/application/member/MemberService.java index 1095750d..80bfe3a1 100644 --- a/src/main/java/com/atwoz/member/application/member/MemberService.java +++ b/src/main/java/com/atwoz/member/application/member/MemberService.java @@ -1,7 +1,6 @@ package com.atwoz.member.application.member; import com.atwoz.member.application.member.dto.MemberInitializeRequest; -import com.atwoz.member.application.member.dto.MemberNicknameRequest; import com.atwoz.member.application.member.dto.MemberUpdateRequest; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.MemberRepository; @@ -30,17 +29,6 @@ public void create(final String phoneNumber) { memberRepository.save(Member.createWithOAuth(phoneNumber)); } - @Transactional(readOnly = true) - public void checkMemberExists(final MemberNicknameRequest memberNicknameRequest) { - validateNicknameIsUnique(memberNicknameRequest.nickname()); - } - - private void validateNicknameIsUnique(final String nickname) { - if (memberRepository.existsByNickname(nickname)) { - throw new MemberNicknameAlreadyExistedException(); - } - } - public void initializeMember(final Long memberId, final MemberInitializeRequest memberInitializeRequest) { Member foundMember = findMemberById(memberId); MemberProfileDto memberProfileDto = MemberProfileDto.createWith( @@ -50,6 +38,12 @@ public void initializeMember(final Long memberId, final MemberInitializeRequest foundMember.initializeWith(memberInitializeRequest.nickname(), foundRecommenderId, memberProfileDto); } + private void validateNicknameIsUnique(final String nickname) { + if (memberRepository.existsByNickname(nickname)) { + throw new MemberNicknameAlreadyExistedException(); + } + } + private Member findMemberById(final Long memberId) { return memberRepository.findById(memberId) .orElseThrow(MemberNotFoundException::new); diff --git a/src/main/java/com/atwoz/member/application/member/dto/MemberNicknameRequest.java b/src/main/java/com/atwoz/member/application/member/dto/MemberNicknameRequest.java deleted file mode 100644 index 169f4c24..00000000 --- a/src/main/java/com/atwoz/member/application/member/dto/MemberNicknameRequest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.atwoz.member.application.member.dto; - -import jakarta.validation.constraints.NotBlank; - -public record MemberNicknameRequest( - @NotBlank(message = "닉네임을 입력해주세요.") - String nickname -){ -} diff --git a/src/main/java/com/atwoz/member/domain/member/MemberRepository.java b/src/main/java/com/atwoz/member/domain/member/MemberRepository.java index 71fb086b..5a389aa3 100644 --- a/src/main/java/com/atwoz/member/domain/member/MemberRepository.java +++ b/src/main/java/com/atwoz/member/domain/member/MemberRepository.java @@ -1,5 +1,6 @@ package com.atwoz.member.domain.member; +import com.atwoz.member.infrastructure.member.dto.MemberResponse; import java.util.Optional; public interface MemberRepository { @@ -10,6 +11,8 @@ public interface MemberRepository { Optional findByNickname(String nickname); + MemberResponse findMemberWithId(Long id); + Member save(Member member); boolean existsByPhoneNumber(String phoneNumber); diff --git a/src/main/java/com/atwoz/member/domain/member/profile/vo/MemberHobbies.java b/src/main/java/com/atwoz/member/domain/member/profile/MemberHobbies.java similarity index 57% rename from src/main/java/com/atwoz/member/domain/member/profile/vo/MemberHobbies.java rename to src/main/java/com/atwoz/member/domain/member/profile/MemberHobbies.java index 80f54945..11200d43 100644 --- a/src/main/java/com/atwoz/member/domain/member/profile/vo/MemberHobbies.java +++ b/src/main/java/com/atwoz/member/domain/member/profile/MemberHobbies.java @@ -1,46 +1,47 @@ -package com.atwoz.member.domain.member.profile.vo; +package com.atwoz.member.domain.member.profile; +import com.atwoz.member.domain.member.profile.vo.Hobby; import com.atwoz.member.exception.exceptions.member.profile.HobbyDuplicateException; import com.atwoz.member.exception.exceptions.member.profile.HobbySizeException; import com.atwoz.member.exception.exceptions.member.profile.InvalidHobbyException; -import jakarta.persistence.CollectionTable; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Embeddable; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@Embeddable +@EqualsAndHashCode(of = "id") @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PUBLIC) +@Entity public class MemberHobbies { private static final int MIN_HOBBY_SIZE = 1; private static final int MAX_HOBBY_SIZE = 3; - @ElementCollection - @CollectionTable(name = "HOBBIES", joinColumns = @JoinColumn(name = "profile_id")) - @Enumerated(EnumType.STRING) - private Set hobbies = new HashSet<>(); + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - public MemberHobbies changeWith(final List hobbyCodes) { - validateHobbyCodes(hobbyCodes); - Set uniqueHobbies = convertToUniqueHobbies(hobbyCodes); - - if (isSameAsCurrentValue(uniqueHobbies)) { - return new MemberHobbies(this.hobbies); - } + @JoinColumn(name = "member_hobbies_id") + @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval = true, fetch = FetchType.LAZY) + private Set hobbies = new HashSet<>(); - return new MemberHobbies(uniqueHobbies); + public void change(final List hobbyCodes) { + validateHobbyCodes(hobbyCodes); + changeHobbies(hobbyCodes); } private void validateHobbyCodes(final List hobbyCodes) { @@ -76,13 +77,16 @@ private boolean hasInvalidHobbyCode(final List hobbyCodes) { .anyMatch(hobbyCode -> !Hobby.isValidCode(hobbyCode)); } - private Set convertToUniqueHobbies(final List hobbyCodes) { - return hobbyCodes.stream() - .map(Hobby::findByCode) - .collect(Collectors.toSet()); + private void changeHobbies(final List hobbyCodes) { + hobbies.removeIf(memberHobby -> !memberHobby.hasMatchingHobbyCodeOf(hobbyCodes)); + hobbyCodes.stream() + .map(MemberHobby::createWith) + .filter(memberHobby -> !isAlreadyExist(memberHobby)) + .forEach(memberHobby -> hobbies.add(memberHobby)); } - private boolean isSameAsCurrentValue(final Set uniqueHobbies) { - return uniqueHobbies.equals(this.hobbies); + private boolean isAlreadyExist(final MemberHobby memberHobby) { + return hobbies.stream() + .anyMatch(memberHobby::isSame); } } diff --git a/src/main/java/com/atwoz/member/domain/member/profile/MemberHobby.java b/src/main/java/com/atwoz/member/domain/member/profile/MemberHobby.java new file mode 100644 index 00000000..a2312010 --- /dev/null +++ b/src/main/java/com/atwoz/member/domain/member/profile/MemberHobby.java @@ -0,0 +1,44 @@ +package com.atwoz.member.domain.member.profile; + +import com.atwoz.member.domain.member.profile.vo.Hobby; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +public class MemberHobby { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Enumerated(EnumType.STRING) + private Hobby hobby; + + public static MemberHobby createWith(final String hobbyCode) { + return MemberHobby.builder() + .hobby(Hobby.findByCode(hobbyCode)) + .build(); + } + + public boolean hasMatchingHobbyCodeOf(final List hobbyCodes) { + return hobbyCodes.contains(hobby.getCode()); + } + + public boolean isSame(final MemberHobby memberHobby) { + return this.hobby.equals(memberHobby.hobby); + } +} diff --git a/src/main/java/com/atwoz/member/domain/member/profile/MemberStyle.java b/src/main/java/com/atwoz/member/domain/member/profile/MemberStyle.java new file mode 100644 index 00000000..161665ef --- /dev/null +++ b/src/main/java/com/atwoz/member/domain/member/profile/MemberStyle.java @@ -0,0 +1,44 @@ +package com.atwoz.member.domain.member.profile; + +import com.atwoz.member.domain.member.profile.vo.Style; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +public class MemberStyle { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Enumerated(EnumType.STRING) + private Style style; + + public static MemberStyle createWith(final String styleCode) { + return MemberStyle.builder() + .style(Style.findByCode(styleCode)) + .build(); + } + + public boolean hasMatchingStyleCodeOf(final List styleCodes) { + return styleCodes.contains(style.getCode()); + } + + public boolean isSame(final MemberStyle memberStyle) { + return this.style.equals(memberStyle.style); + } +} diff --git a/src/main/java/com/atwoz/member/domain/member/profile/vo/MemberStyles.java b/src/main/java/com/atwoz/member/domain/member/profile/MemberStyles.java similarity index 57% rename from src/main/java/com/atwoz/member/domain/member/profile/vo/MemberStyles.java rename to src/main/java/com/atwoz/member/domain/member/profile/MemberStyles.java index 15782815..f5c43458 100644 --- a/src/main/java/com/atwoz/member/domain/member/profile/vo/MemberStyles.java +++ b/src/main/java/com/atwoz/member/domain/member/profile/MemberStyles.java @@ -1,46 +1,47 @@ -package com.atwoz.member.domain.member.profile.vo; +package com.atwoz.member.domain.member.profile; +import com.atwoz.member.domain.member.profile.vo.Style; import com.atwoz.member.exception.exceptions.member.profile.InvalidStyleException; import com.atwoz.member.exception.exceptions.member.profile.StyleDuplicateException; import com.atwoz.member.exception.exceptions.member.profile.StyleSizeException; -import jakarta.persistence.CollectionTable; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Embeddable; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@Embeddable +@EqualsAndHashCode(of = "id") @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PUBLIC) +@Entity public class MemberStyles { private static final int MIN_STYLE_SIZE = 1; private static final int MAX_STYLE_SIZE = 3; - @ElementCollection - @CollectionTable(name = "STYLES", joinColumns = @JoinColumn(name = "profile_id")) - @Enumerated(EnumType.STRING) - private Set