diff --git a/src/docs/asciidoc/selfIntro.adoc b/src/docs/asciidoc/selfIntro.adoc index f7ec5a8f..62ee216b 100644 --- a/src/docs/asciidoc/selfIntro.adoc +++ b/src/docs/asciidoc/selfIntro.adoc @@ -17,19 +17,6 @@ include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_저장/r ==== 응답 include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_저장/http-response.adoc[] - -=== 셀프 소개글 페이징 조회 (GET /api/members/self-intros) - -==== 요청 -include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/http-request.adoc[] -include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/request-headers.adoc[] -include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/request-parts.adoc[] - -==== 응답 -include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/http-response.adoc[] -include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/response-fields.adoc[] - - === 셀프 소개글 페이징 조회 (필터 적용) (Get /api/members/self-intros/filter) ==== 요청 diff --git a/src/main/java/com/atwoz/member/application/auth/MemberAuthService.java b/src/main/java/com/atwoz/member/application/auth/MemberAuthService.java index 672f9036..c9f53bae 100644 --- a/src/main/java/com/atwoz/member/application/auth/MemberAuthService.java +++ b/src/main/java/com/atwoz/member/application/auth/MemberAuthService.java @@ -3,6 +3,7 @@ import com.atwoz.alert.application.event.AlertTokenCreatedEvent; import com.atwoz.global.event.Events; import com.atwoz.member.application.auth.dto.LoginRequest; +import com.atwoz.member.application.auth.dto.TestLoginRequest; import com.atwoz.member.domain.auth.MemberTokenProvider; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.MemberRepository; @@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor +@Transactional @Service public class MemberAuthService { @@ -25,7 +27,6 @@ public class MemberAuthService { /** * OAuth 인증방식과 PASS 인증 방식에 차이가 존재해서 회의 후 메서드 변경을 진행할 예정 */ - @Transactional public String login(final LoginRequest request, final OAuthProviderRequest provider) { String accessToken = oAuthRequester.getAccessToken(request.code(), provider); MemberInfoResponse memberInfoResponse = oAuthRequester.getMemberInfo(accessToken, provider); @@ -36,4 +37,12 @@ public String login(final LoginRequest request, final OAuthProviderRequest provi return memberTokenProvider.createAccessToken(createdMember.getId()); } + + //TODO: test를 위해 임시로 구현한 메서드입니다. 나중에 삭제해야합니다. + public String testLogin(final TestLoginRequest request) { + Member member = Member.createWithOAuth(request.phoneNumber()); + memberRepository.save(member); + + return memberTokenProvider.createAccessToken(member.getId()); + } } diff --git a/src/main/java/com/atwoz/member/application/auth/dto/TestLoginRequest.java b/src/main/java/com/atwoz/member/application/auth/dto/TestLoginRequest.java new file mode 100644 index 00000000..a89ff5bc --- /dev/null +++ b/src/main/java/com/atwoz/member/application/auth/dto/TestLoginRequest.java @@ -0,0 +1,7 @@ +package com.atwoz.member.application.auth.dto; + +//TODO 잠깐 테스트 용도로 로그인을 허용하기 위해 만든 dto입니다. 나중에 삭제해야합니다. +public record TestLoginRequest( + String phoneNumber +) { +} diff --git a/src/main/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryService.java b/src/main/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryService.java index c204206e..199e3503 100644 --- a/src/main/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryService.java +++ b/src/main/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryService.java @@ -1,11 +1,12 @@ package com.atwoz.member.application.member.profile.hobby; import com.atwoz.global.application.BaseQueryService; -import com.atwoz.member.application.member.profile.hobby.dto.HobbyResponses; +import com.atwoz.member.application.member.profile.hobby.dto.HobbyPagingResponses; import com.atwoz.member.domain.member.profile.Hobby; import com.atwoz.member.domain.member.profile.HobbyRepository; import com.atwoz.member.exception.exceptions.member.profile.hobby.HobbyNotFoundException; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbySingleResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -15,13 +16,13 @@ @RequiredArgsConstructor @Service @Transactional(readOnly = true) -public class HobbyQueryService extends BaseQueryService { +public class HobbyQueryService extends BaseQueryService { private final HobbyRepository hobbyRepository; - public HobbyResponse findHobby(final Long hobbyId) { + public HobbySingleResponse findHobby(final Long hobbyId) { Hobby foundHobby = findMemberHobbyById(hobbyId); - return HobbyResponse.from(foundHobby); + return HobbySingleResponse.from(foundHobby); } private Hobby findMemberHobbyById(final Long hobbyId) { @@ -29,10 +30,10 @@ private Hobby findMemberHobbyById(final Long hobbyId) { .orElseThrow(HobbyNotFoundException::new); } - public HobbyResponses findHobbiesWithPaging(final Pageable pageable) { - Page hobbyResponses = hobbyRepository.findHobbiesWithPaging(pageable); + public HobbyPagingResponses findHobbiesWithPaging(final Pageable pageable) { + Page hobbyResponses = hobbyRepository.findHobbiesWithPaging(pageable); int nextPage = getNextPage(pageable.getPageNumber(), hobbyResponses); - return HobbyResponses.of(hobbyResponses, pageable, nextPage); + return HobbyPagingResponses.of(hobbyResponses, pageable, nextPage); } } diff --git a/src/main/java/com/atwoz/member/application/member/profile/hobby/dto/HobbyResponses.java b/src/main/java/com/atwoz/member/application/member/profile/hobby/dto/HobbyPagingResponses.java similarity index 70% rename from src/main/java/com/atwoz/member/application/member/profile/hobby/dto/HobbyResponses.java rename to src/main/java/com/atwoz/member/application/member/profile/hobby/dto/HobbyPagingResponses.java index a915066f..6f969b0c 100644 --- a/src/main/java/com/atwoz/member/application/member/profile/hobby/dto/HobbyResponses.java +++ b/src/main/java/com/atwoz/member/application/member/profile/hobby/dto/HobbyPagingResponses.java @@ -1,14 +1,14 @@ package com.atwoz.member.application.member.profile.hobby.dto; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; import java.util.List; import lombok.Builder; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @Builder -public record HobbyResponses( - List hobbyResponses, +public record HobbyPagingResponses( + List hobbyPagingResponses, int nowPage, int nextPage, int totalPages, @@ -18,13 +18,13 @@ public record HobbyResponses( private static final int NEXT_PAGE = 1; private static final int NO_MORE_PAGE = -1; - public static HobbyResponses of( - final Page hobbyResponses, + public static HobbyPagingResponses of( + final Page hobbyResponses, final Pageable pageable, final int nextPage ) { - return HobbyResponses.builder() - .hobbyResponses(hobbyResponses.getContent()) + return HobbyPagingResponses.builder() + .hobbyPagingResponses(hobbyResponses.getContent()) .nowPage(pageable.getPageNumber()) .nextPage(nextPage) .totalPages(hobbyResponses.getTotalPages()) diff --git a/src/main/java/com/atwoz/member/application/member/profile/style/StyleQueryService.java b/src/main/java/com/atwoz/member/application/member/profile/style/StyleQueryService.java index 9a7005e1..683640d4 100644 --- a/src/main/java/com/atwoz/member/application/member/profile/style/StyleQueryService.java +++ b/src/main/java/com/atwoz/member/application/member/profile/style/StyleQueryService.java @@ -1,11 +1,12 @@ package com.atwoz.member.application.member.profile.style; import com.atwoz.global.application.BaseQueryService; -import com.atwoz.member.application.member.profile.style.dto.StyleResponses; +import com.atwoz.member.application.member.profile.style.dto.StylePagingResponses; import com.atwoz.member.domain.member.profile.Style; import com.atwoz.member.domain.member.profile.StyleRepository; import com.atwoz.member.exception.exceptions.member.profile.style.StyleNotFoundException; -import com.atwoz.member.infrastructure.member.profile.style.dto.StyleResponse; +import com.atwoz.member.infrastructure.member.profile.style.dto.StylePagingResponse; +import com.atwoz.member.infrastructure.member.profile.style.dto.StyleSingleResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -15,13 +16,13 @@ @RequiredArgsConstructor @Service @Transactional(readOnly = true) -public class StyleQueryService extends BaseQueryService { +public class StyleQueryService extends BaseQueryService { private final StyleRepository styleRepository; - public StyleResponse findStyle(final Long styleId) { + public StyleSingleResponse findStyle(final Long styleId) { Style foundStyle = findStyleById(styleId); - return StyleResponse.from(foundStyle); + return StyleSingleResponse.from(foundStyle); } private Style findStyleById(final Long styleId) { @@ -29,9 +30,9 @@ private Style findStyleById(final Long styleId) { .orElseThrow(StyleNotFoundException::new); } - public StyleResponses findStylesWithPaging(final Pageable pageable) { - Page styleResponses = styleRepository.findStylesWithPaging(pageable); + public StylePagingResponses findStylesWithPaging(final Pageable pageable) { + Page styleResponses = styleRepository.findStylesWithPaging(pageable); int nextPage = getNextPage(pageable.getPageNumber(), styleResponses); - return StyleResponses.of(styleResponses, pageable, nextPage); + return StylePagingResponses.of(styleResponses, pageable, nextPage); } } diff --git a/src/main/java/com/atwoz/member/application/member/profile/style/dto/StyleResponses.java b/src/main/java/com/atwoz/member/application/member/profile/style/dto/StylePagingResponses.java similarity index 70% rename from src/main/java/com/atwoz/member/application/member/profile/style/dto/StyleResponses.java rename to src/main/java/com/atwoz/member/application/member/profile/style/dto/StylePagingResponses.java index b0b80d8b..80c546f5 100644 --- a/src/main/java/com/atwoz/member/application/member/profile/style/dto/StyleResponses.java +++ b/src/main/java/com/atwoz/member/application/member/profile/style/dto/StylePagingResponses.java @@ -1,14 +1,14 @@ package com.atwoz.member.application.member.profile.style.dto; -import com.atwoz.member.infrastructure.member.profile.style.dto.StyleResponse; +import com.atwoz.member.infrastructure.member.profile.style.dto.StylePagingResponse; import java.util.List; import lombok.Builder; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @Builder -public record StyleResponses( - List styleResponses, +public record StylePagingResponses( + List stylePagingResponses, int nowPage, int nextPage, int totalPages, @@ -18,13 +18,13 @@ public record StyleResponses( private static final int NEXT_PAGE = 1; private static final int NO_MORE_PAGE = -1; - public static StyleResponses of( - final Page styleResponses, + public static StylePagingResponses of( + final Page styleResponses, final Pageable pageable, final int nextPage ) { - return StyleResponses.builder() - .styleResponses(styleResponses.getContent()) + return StylePagingResponses.builder() + .stylePagingResponses(styleResponses.getContent()) .nowPage(pageable.getPageNumber()) .nextPage(nextPage) .totalPages(styleResponses.getTotalPages()) diff --git a/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java b/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java index f9cf6e90..9a4b0948 100644 --- a/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java +++ b/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java @@ -18,12 +18,6 @@ public class SelfIntroQueryService extends BaseQueryService { private final SelfIntroRepository selfIntroRepository; - public SelfIntroResponses findAllSelfIntrosWithPaging(final Pageable pageable) { - Page selfIntroResponses = selfIntroRepository.findAllSelfIntrosWithPaging(pageable); - int nextPage = getNextPage(pageable.getPageNumber(), selfIntroResponses); - return SelfIntroResponses.of(selfIntroResponses, pageable, nextPage); - } - public SelfIntroResponses findAllSelfIntrosWithPagingAndFiltering( final Pageable pageable, final SelfIntroFilterRequest selfIntroFilterRequest, @@ -34,7 +28,7 @@ public SelfIntroResponses findAllSelfIntrosWithPagingAndFiltering( selfIntroFilterRequest.minAge(), selfIntroFilterRequest.maxAge(), selfIntroFilterRequest.isOnlyOppositeGender(), - selfIntroFilterRequest.getCities(), + selfIntroFilterRequest.cities(), memberId ); int nextPage = getNextPage(pageable.getPageNumber(), selfIntroResponses); diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java b/src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java deleted file mode 100644 index 99c22587..00000000 --- a/src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.atwoz.member.application.selfintro.dto; - -import jakarta.validation.constraints.NotBlank; - -public record CityRequest( - - @NotBlank(message = "선호하는 지역 정보를 입력해주세요.") - String city -) { -} diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java index c133541f..802a4323 100644 --- a/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java +++ b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java @@ -1,29 +1,37 @@ package com.atwoz.member.application.selfintro.dto; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import java.util.Collections; import java.util.List; public record SelfIntroFilterRequest( - - @NotNull(message = "최소 나이를 입력해주세요") Integer minAge, - - @NotNull(message = "최대 나이를 입력해주세요") Integer maxAge, - - @NotNull(message = "성별을 선택해주세요") Boolean isOnlyOppositeGender, - - @Valid - @NotEmpty(message = "선호 지역을 하나 이상 입력해주세요.") - List cityRequests + List cities ) { - public List getCities() { - return cityRequests.stream() - .map(CityRequest::city) - .toList(); + public SelfIntroFilterRequest( + final Integer minAge, + final Integer maxAge, + final Boolean isOnlyOppositeGender, + final List cities + ) { + this.minAge = minAge; + this.maxAge = maxAge; + this.isOnlyOppositeGender = isOnlyOppositeGender; + this.cities = ensureCities(cities); + } + + private List ensureCities(final List cities) { + if (isInvalidCase(cities)) { + return Collections.emptyList(); + } + return cities; + } + + private boolean isInvalidCase(final List cities) { + return cities == null || + cities.stream() + .allMatch(city -> city == null || city.isBlank()); } } diff --git a/src/main/java/com/atwoz/member/domain/member/Member.java b/src/main/java/com/atwoz/member/domain/member/Member.java index 11fa220c..675cc90f 100644 --- a/src/main/java/com/atwoz/member/domain/member/Member.java +++ b/src/main/java/com/atwoz/member/domain/member/Member.java @@ -82,9 +82,11 @@ public static Member createWithPass(final String gender, .build(); } - public void initializeWith(final String nickname, - final Long recommenderId, - final InternalProfileInitializeRequest internalProfileInitializeRequest) { + public void initializeWith( + final String nickname, + final Long recommenderId, + final InternalProfileInitializeRequest internalProfileInitializeRequest + ) { this.nickname = nickname; initializeRecommenderId(recommenderId); memberProfile.initialize(internalProfileInitializeRequest); diff --git a/src/main/java/com/atwoz/member/domain/member/profile/HobbyRepository.java b/src/main/java/com/atwoz/member/domain/member/profile/HobbyRepository.java index 89bd5752..5d51f675 100644 --- a/src/main/java/com/atwoz/member/domain/member/profile/HobbyRepository.java +++ b/src/main/java/com/atwoz/member/domain/member/profile/HobbyRepository.java @@ -1,6 +1,6 @@ package com.atwoz.member.domain.member.profile; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -15,7 +15,7 @@ public interface HobbyRepository { Optional findHobbyByCode(String hobbyCode); - Page findHobbiesWithPaging(Pageable pageable); + Page findHobbiesWithPaging(Pageable pageable); void deleteById(Long hobbyId); } diff --git a/src/main/java/com/atwoz/member/domain/member/profile/StyleRepository.java b/src/main/java/com/atwoz/member/domain/member/profile/StyleRepository.java index 93d5b351..2215090b 100644 --- a/src/main/java/com/atwoz/member/domain/member/profile/StyleRepository.java +++ b/src/main/java/com/atwoz/member/domain/member/profile/StyleRepository.java @@ -1,6 +1,6 @@ package com.atwoz.member.domain.member.profile; -import com.atwoz.member.infrastructure.member.profile.style.dto.StyleResponse; +import com.atwoz.member.infrastructure.member.profile.style.dto.StylePagingResponse; import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -15,7 +15,7 @@ public interface StyleRepository { Optional