From 035c4ce4bc594280523e849cf2163f2594782560 Mon Sep 17 00:00:00 2001 From: eom-tae-in Date: Wed, 25 Sep 2024 18:43:17 +0900 Subject: [PATCH 01/11] =?UTF-8?q?refactor:=20=EC=85=80=ED=94=84=20?= =?UTF-8?q?=EC=86=8C=EA=B0=9C=EA=B8=80=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B4=80=EB=A0=A8=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=ED=95=98=EB=82=98=EB=A1=9C=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../selfintro/SelfIntroQueryService.java | 8 +-- .../selfintro/dto/CityRequest.java | 10 --- .../selfintro/dto/SelfIntroFilterRequest.java | 42 +++++++----- .../domain/selfintro/SelfIntroRepository.java | 8 +-- .../selfintro/SelfIntroQueryRepository.java | 68 ++++++++----------- .../selfintro/SelfIntroRepositoryImpl.java | 19 +++--- .../ui/selfintro/SelfIntroController.java | 35 +++++----- 7 files changed, 85 insertions(+), 105 deletions(-) delete mode 100644 src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java 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/selfintro/SelfIntroRepository.java b/src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java index 53cb8a08..cf484464 100644 --- a/src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java +++ b/src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java @@ -14,13 +14,11 @@ public interface SelfIntroRepository { void deleteById(Long id); - Page findAllSelfIntrosWithPaging(Pageable pageable); - Page findAllSelfIntrosWithPagingAndFiltering( Pageable pageable, - int minAge, - int maxAge, - boolean isOnlyOppositeGender, + Integer minAge, + Integer maxAge, + Boolean isOnlyOppositeGender, List cities, Long memberId ); diff --git a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java index 86ed3ffc..a492b5aa 100644 --- a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java +++ b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java @@ -2,6 +2,7 @@ import com.atwoz.member.domain.member.profile.physical.vo.Gender; import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -25,28 +26,6 @@ public class SelfIntroQueryRepository { private final JPAQueryFactory jpaQueryFactory; - public Page findAllSelfIntroWithPaging(final Pageable pageable) { - List fetch = selectSelfIntroResponse() - .from(member) - .leftJoin(member.memberProfile, memberProfile) - .leftJoin(memberProfile.profile, profile) - .leftJoin(profile.physicalProfile, physicalProfile) - .leftJoin(selfIntro).on(member.id.eq(selfIntro.memberId)) - .orderBy(selfIntro.createdAt.desc()) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); - - JPAQuery count = jpaQueryFactory.select(member.count()) - .from(member) - .leftJoin(member.memberProfile, memberProfile) - .leftJoin(memberProfile.profile, profile) - .leftJoin(profile.physicalProfile, physicalProfile) - .leftJoin(selfIntro).on(member.id.eq(selfIntro.memberId)); - - return PageableExecutionUtils.getPage(fetch, pageable, count::fetchOne); - } - private JPAQuery selectSelfIntroResponse() { return jpaQueryFactory.select( constructor(SelfIntroResponse.class, @@ -70,12 +49,14 @@ private Gender findMemberGender(final Long memberId) { .fetchFirst(); } - public Page findAllSelfIntrosWithPagingAndFiltering(final Pageable pageable, - final int minAge, - final int maxAge, - final boolean isOnlyOppositeGender, - final List cities, - final Long memberId) { + public Page findAllSelfIntrosWithPagingAndFiltering( + final Pageable pageable, + final Integer minAge, + final Integer maxAge, + final Boolean isOnlyOppositeGender, + final List cities, + final Long memberId + ) { Gender memberGender = findMemberGender(memberId); List fetch = selectSelfIntroResponse() .from(selfIntro) @@ -86,8 +67,8 @@ public Page findAllSelfIntrosWithPagingAndFiltering(final Pag .orderBy(selfIntro.createdAt.desc()) .where( applyGenderCondition(isOnlyOppositeGender, memberGender), - ageBetween(minAge, maxAge), - locationIn(cities) + applyAgeCondition(minAge, maxAge), + applyLocationCondition(cities) ) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) @@ -101,27 +82,38 @@ public Page findAllSelfIntrosWithPagingAndFiltering(final Pag .leftJoin(profile.physicalProfile, physicalProfile) .where( applyGenderCondition(isOnlyOppositeGender, memberGender), - ageBetween(minAge, maxAge), - locationIn(cities) + applyAgeCondition(minAge, maxAge), + applyLocationCondition(cities) ); return PageableExecutionUtils.getPage(fetch, pageable, count::fetchOne); } - private BooleanExpression applyGenderCondition(final boolean isOnlyOppositeGender, final Gender gender) { - if (!isOnlyOppositeGender) { + private BooleanExpression applyGenderCondition(final Boolean isOnlyOppositeGender, final Gender gender) { + if (isOnlyOppositeGender == null || !isOnlyOppositeGender) { return null; } return physicalProfile.gender.ne(gender); } - private BooleanExpression ageBetween(final int minAge, final int maxAge) { - return physicalProfile.age.goe(minAge) - .and(physicalProfile.age.loe(maxAge)); + private BooleanBuilder applyAgeCondition(final Integer minAge, final Integer maxAge) { + BooleanBuilder booleanBuilder = new BooleanBuilder(); + if (minAge != null) { + booleanBuilder.and(physicalProfile.age.goe(minAge)); + } + if (maxAge != null) { + booleanBuilder.and(physicalProfile.age.loe(maxAge)); + } + + return booleanBuilder; } - private BooleanExpression locationIn(final List cities) { + private BooleanExpression applyLocationCondition(final List cities) { + if (cities.isEmpty()) { + return null; + } + return profile.location.city.in(cities); } } diff --git a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java index b62adc48..2fb0f259 100644 --- a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java +++ b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java @@ -33,17 +33,14 @@ public void deleteById(final Long id) { } @Override - public Page findAllSelfIntrosWithPaging(final Pageable pageable) { - return selfIntroQueryRepository.findAllSelfIntroWithPaging(pageable); - } - - @Override - public Page findAllSelfIntrosWithPagingAndFiltering(final Pageable pageable, - final int minAge, - final int maxAge, - final boolean isOnlyOppositeGender, - final List cities, - final Long memberId) { + public Page findAllSelfIntrosWithPagingAndFiltering( + final Pageable pageable, + final Integer minAge, + final Integer maxAge, + final Boolean isOnlyOppositeGender, + final List cities, + final Long memberId + ) { return selfIntroQueryRepository.findAllSelfIntrosWithPagingAndFiltering( pageable, minAge, diff --git a/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java b/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java index 2c8f29b0..5766d70d 100644 --- a/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java +++ b/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java @@ -35,35 +35,34 @@ public class SelfIntroController { private final SelfIntroQueryService selfIntroQueryService; @PostMapping("/me") - public ResponseEntity saveSelfIntro(@RequestBody @Valid final SelfIntroCreateRequest selfIntroCreateRequest, - @AuthMember final Long memberId) { + public ResponseEntity saveSelfIntro( + @RequestBody @Valid final SelfIntroCreateRequest selfIntroCreateRequest, + @AuthMember final Long memberId + ) { selfIntroService.saveSelfIntro(selfIntroCreateRequest, memberId); return ResponseEntity.ok() .build(); } - @GetMapping - public ResponseEntity findAllSelfIntrosWithPaging( - @PageableDefault(sort = CREATION_TIME, direction = Direction.DESC) final Pageable pageable) { - return ResponseEntity.ok(selfIntroQueryService.findAllSelfIntrosWithPaging(pageable)); - } - @GetMapping("/filter") public ResponseEntity findAllSelfIntrosWithPagingAndFiltering( @PageableDefault(sort = CREATION_TIME, direction = Direction.DESC) final Pageable pageable, - @ModelAttribute @Valid final SelfIntroFilterRequest selfIntroFilterRequest, + @ModelAttribute final SelfIntroFilterRequest selfIntroFilterRequest, @AuthMember final Long memberId ) { - return ResponseEntity.ok( - selfIntroQueryService.findAllSelfIntrosWithPagingAndFiltering(pageable, selfIntroFilterRequest, - memberId)); + return ResponseEntity.ok(selfIntroQueryService.findAllSelfIntrosWithPagingAndFiltering( + pageable, + selfIntroFilterRequest, + memberId + )); } @PatchMapping("/{id}") - public ResponseEntity updateSelfIntro(@PathVariable("id") final Long selfIntroId, - @RequestBody @Valid final SelfIntroUpdateRequest selfIntroUpdateRequest, - @AuthMember final Long memberId + public ResponseEntity updateSelfIntro( + @PathVariable("id") final Long selfIntroId, + @RequestBody @Valid final SelfIntroUpdateRequest selfIntroUpdateRequest, + @AuthMember final Long memberId ) { selfIntroService.updateSelfIntro(selfIntroUpdateRequest, selfIntroId, memberId); @@ -72,8 +71,10 @@ public ResponseEntity updateSelfIntro(@PathVariable("id") final Long selfI } @DeleteMapping("/{id}") - public ResponseEntity deleteSelfIntro(@PathVariable("id") final Long selfIntroId, - @AuthMember final Long memberId) { + public ResponseEntity deleteSelfIntro( + @PathVariable("id") final Long selfIntroId, + @AuthMember final Long memberId + ) { selfIntroService.deleteSelfIntro(selfIntroId, memberId); return ResponseEntity.noContent() From 9a110335dd945e2f161f2a08f2ffabd271c3f76f Mon Sep 17 00:00:00 2001 From: eom-tae-in Date: Wed, 25 Sep 2024 18:43:40 +0900 Subject: [PATCH 02/11] =?UTF-8?q?test:=20=EC=85=80=ED=94=84=20=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EA=B8=80=20api=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B8=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../selfintro/SelfIntroQueryServiceTest.java | 22 ---------- .../selfintro/SelfIntroRequestFixture.java | 3 +- .../selfintro/SelfIntroFakeRepository.java | 24 ++++------- .../SelfIntroControllerAcceptanceTest.java | 12 ------ ...fIntroControllerAcceptanceTestFixture.java | 2 +- .../SelfIntroControllerWebMvcTest.java | 41 +------------------ 6 files changed, 11 insertions(+), 93 deletions(-) diff --git a/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java b/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java index d30154e3..b18f677c 100644 --- a/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java +++ b/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java @@ -29,28 +29,6 @@ void setup() { selfIntroQueryService = new SelfIntroQueryService(selfIntroRepository); } - @Test - void 셀프_소개글을_페이징으로_조회한다() { - // given - SelfIntro selfIntro = 셀프_소개글_생성_id_있음(1L); - PageRequest pageRequest = PageRequest.of(0, 10); - selfIntroRepository.save(selfIntro); - - // when - SelfIntroResponses result = selfIntroQueryService.findAllSelfIntrosWithPaging(pageRequest); - - // then - assertSoftly(softly -> { - softly.assertThat(result.nowPage()).isEqualTo(0); - softly.assertThat(result.nextPage()).isEqualTo(-1); - softly.assertThat(result.totalPages()).isEqualTo(1); - softly.assertThat(result.totalElements()).isEqualTo(1); - SelfIntroResponse selfIntroResponse = result.selfIntros().get(0); - softly.assertThat(selfIntroResponse.selfIntroId()).isEqualTo(selfIntro.getId()); - softly.assertThat(selfIntroResponse.selfIntroContent()).isEqualTo(selfIntro.getContent()); - }); - } - @Test void 필터를_적용한_셀프_소개글을_페이징으로_조회한다() { // given diff --git a/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java index 213b95b4..a9f335ba 100644 --- a/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java +++ b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java @@ -1,6 +1,5 @@ package com.atwoz.member.fixture.selfintro; -import com.atwoz.member.application.selfintro.dto.CityRequest; import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; import com.atwoz.member.application.selfintro.dto.SelfIntroFilterRequest; import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; @@ -25,7 +24,7 @@ public class SelfIntroRequestFixture { MIN_AGE, MAX_AGE, IS_ONLY_OPPOSITE_GENDER, - List.of(new CityRequest(CITY)) + List.of(CITY) ); } diff --git a/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java index 92cfa012..c9a244f0 100644 --- a/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java +++ b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java @@ -46,33 +46,23 @@ public void deleteById(final Long id) { map.remove(id); } - @Override - public Page findAllSelfIntrosWithPaging(final Pageable pageable) { - List introResponses = map.values().stream() - .sorted(Comparator.comparing(SelfIntro::getCreatedAt).reversed()) - .limit(SIZE_PER_PAGE) - .map(selfIntro -> 셀프_소개글_응답(selfIntro.getId(), selfIntro.getContent() - )).toList(); - - return new PageImpl<>(introResponses); - } - @Override public Page findAllSelfIntrosWithPagingAndFiltering( final Pageable pageable, - final int minAge, - final int maxAge, - final boolean isOnlyOppositeGender, + final Integer minAge, + final Integer maxAge, + final Boolean isOnlyOppositeGender, final List cities, final Long memberId ) { - List introResponses = map.values().stream() + List introResponses = map.values() + .stream() .filter(selfIntro -> isBetween(minAge, maxAge)) .filter(selfIntro -> isBelongTo(cities)) .sorted(Comparator.comparing(SelfIntro::getCreatedAt).reversed()) .limit(SIZE_PER_PAGE) - .map(selfIntro -> 셀프_소개글_응답(selfIntro.getId(), selfIntro.getContent() - )).toList(); + .map(selfIntro -> 셀프_소개글_응답(selfIntro.getId(), selfIntro.getContent())) + .toList(); return new PageImpl<>(introResponses); } diff --git a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java index 05138036..20961010 100644 --- a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java +++ b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java @@ -43,18 +43,6 @@ void setup() { 셀프_소개글_저장_검증(셀프_소개글_저장_요청_결과); } - @Test - void 셀프_소개글_페이징_조회() { - // given - 셀프_소개글_저장(셀프_소개글); - - // when - var 셀프_소개글_페이징_조회_요청_결과 = 셀프_소개글_페이징_조회_요청(셀프_소개글_조회_URL, 토큰); - - // then - 셀프_소개글_페이징_조회_요청_검증(셀프_소개글_페이징_조회_요청_결과); - } - @Test void 필터_적용한_셀프_소개글_페이징_조회() { // given diff --git a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java index c5e750d3..631a1be0 100644 --- a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java +++ b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java @@ -117,7 +117,7 @@ void init() { .param("minAge", "20") .param("maxAge", "30") .param("isOnlyOppositeGender", "false") - .param("cityRequests", "서울시,경기도") + .param("cities", "서울시,경기도") .when() .get(url) .then().log().all() diff --git a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java index 5220f1c8..cec5d9d9 100644 --- a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java +++ b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java @@ -79,43 +79,6 @@ class SelfIntroControllerWebMvcTest extends MockBeanInjection { )); } - @Test - void 셀프_소개글을_페이징으로_조회한다() throws Exception { - // given - List selfIntroResponses = List.of(셀프_소개글_응답()); - when(selfIntroQueryService.findAllSelfIntrosWithPaging(any(Pageable.class))) - .thenReturn(new SelfIntroResponses(selfIntroResponses, 0, 1, 2, 1)); - - // when & then - mockMvc.perform(get("/api/members/self-intros") - .param("page", "0") - .param("size", "10") - .header(AUTHORIZATION, BEARER_TOKEN)) - .andExpect(status().isOk()) - .andDo(print()) - .andDo(customDocument("셀프_소개글_페이징_조회", - requestHeaders( - headerWithName(AUTHORIZATION).description("유저 토큰 정보") - ), - requestParts( - partWithName("page").description("페이지 번호").optional(), - partWithName("size").description("조회되는 데이터 수, 한 페이지당 조회되는 데이터 수입니다.").optional() - ), - responseFields( - fieldWithPath("selfIntros[].selfIntroId").description("셀프 소개글 id"), - fieldWithPath("selfIntros[].selfIntroContent").description("셀프 소개글"), - fieldWithPath("selfIntros[].nickname").description("작성자 닉네임"), - fieldWithPath("selfIntros[].city").description("작성자가 사는 도시"), - fieldWithPath("selfIntros[].age").description("작성자의 나이"), - fieldWithPath("selfIntros[].height").description("작성자의 키"), - fieldWithPath("nowPage").description("현재 페이지"), - fieldWithPath("nextPage").description("다음 페이지, 다음 페이지가 없을 경우 -1을 반환합니다."), - fieldWithPath("totalPages").description("전체 페이지 수"), - fieldWithPath("totalElements").description("전체 조회된 데이터 수") - ) - )); - } - @Test void 셀프_소개글을_필터와_페이징으로_조회한다() throws Exception { // given @@ -131,7 +94,7 @@ class SelfIntroControllerWebMvcTest extends MockBeanInjection { .param("minAge", "20") .param("maxAge", "30") .param("isOnlyOppositeGender", "false") - .param("cityRequests", "서울시,경기도") + .param("cities", "서울시,경기도") .header(AUTHORIZATION, BEARER_TOKEN)) .andExpect(status().isOk()) .andDo(print()) @@ -145,7 +108,7 @@ class SelfIntroControllerWebMvcTest extends MockBeanInjection { partWithName("minAge").description("최소 나이(필터)").optional(), partWithName("maxAge").description("최대 나이(필터)").optional(), partWithName("isOnlyOppositeGender").description("성별 설정(필터), 이 값이 true일 경우 이성만 조회됩니다.").optional(), - partWithName("cityRequests").description("선호 지역(필터), 지역명을 문자열로 제공해주시면 됩니다.").optional() + partWithName("cities").description("선호 지역(필터), 지역명을 문자열로 제공해주시면 됩니다.").optional() ), responseFields( fieldWithPath("selfIntros[].selfIntroId").description("셀프 소개글 id"), From c51fae1d746277d1395ece02ac04e9a1a18b3663 Mon Sep 17 00:00:00 2001 From: eom-tae-in Date: Wed, 25 Sep 2024 18:44:00 +0900 Subject: [PATCH 03/11] =?UTF-8?q?docs:=20=EC=85=80=ED=94=84=20=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EA=B8=80=20api=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B8=ED=95=9C=20=EB=AC=B8=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/selfIntro.adoc | 13 ------------- 1 file changed, 13 deletions(-) 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) ==== 요청 From 55977cb0010de21a1673994d79c94494c1a5080d Mon Sep 17 00:00:00 2001 From: eom-tae-in Date: Wed, 25 Sep 2024 19:29:49 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor:=20=EC=B7=A8=EB=AF=B8=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=95=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EB=90=9C=20=EC=B7=A8=EB=AF=B8=20id=EB=8F=84?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/hobby/HobbyQueryService.java | 17 +++++++++-------- ...esponses.java => HobbyPagingResponses.java} | 14 +++++++------- .../domain/member/profile/HobbyRepository.java | 4 ++-- .../profile/hobby/HobbyQueryRepository.java | 9 +++++---- .../profile/hobby/HobbyRepositoryImpl.java | 4 ++-- .../profile/hobby/dto/HobbyPagingResponse.java | 18 ++++++++++++++++++ .../profile/hobby/dto/HobbyResponse.java | 18 ------------------ .../profile/hobby/dto/HobbySingleResponse.java | 16 ++++++++++++++++ .../member/profile/hobby/HobbyController.java | 8 ++++---- 9 files changed, 63 insertions(+), 45 deletions(-) rename src/main/java/com/atwoz/member/application/member/profile/hobby/dto/{HobbyResponses.java => HobbyPagingResponses.java} (70%) create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyPagingResponse.java delete mode 100644 src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyResponse.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbySingleResponse.java 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/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/infrastructure/member/profile/hobby/HobbyQueryRepository.java b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepository.java index 0dda3eaa..752f18ba 100644 --- a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepository.java +++ b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepository.java @@ -1,6 +1,6 @@ package com.atwoz.member.infrastructure.member.profile.hobby; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; @@ -19,10 +19,11 @@ public class HobbyQueryRepository { private final JPAQueryFactory jpaQueryFactory; - public Page findHobbiesWithPaging(final Pageable pageable) { - List fetch = jpaQueryFactory.select( + public Page findHobbiesWithPaging(final Pageable pageable) { + List fetch = jpaQueryFactory.select( constructor( - HobbyResponse.class, + HobbyPagingResponse.class, + hobby.id, hobby.name, hobby.code ) diff --git a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyRepositoryImpl.java b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyRepositoryImpl.java index 994bef38..dc6d34d1 100644 --- a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyRepositoryImpl.java +++ b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyRepositoryImpl.java @@ -2,7 +2,7 @@ import com.atwoz.member.domain.member.profile.Hobby; import com.atwoz.member.domain.member.profile.HobbyRepository; -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 lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -37,7 +37,7 @@ public Optional findHobbyByCode(final String hobbyCode) { } @Override - public Page findHobbiesWithPaging(final Pageable pageable) { + public Page findHobbiesWithPaging(final Pageable pageable) { return hobbyQueryRepository.findHobbiesWithPaging(pageable); } diff --git a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyPagingResponse.java b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyPagingResponse.java new file mode 100644 index 00000000..fe5430fc --- /dev/null +++ b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyPagingResponse.java @@ -0,0 +1,18 @@ +package com.atwoz.member.infrastructure.member.profile.hobby.dto; + +import com.atwoz.member.domain.member.profile.Hobby; + +public record HobbyPagingResponse( + Long hobbyId, + String name, + String code +) { + + public static HobbyPagingResponse from(final Hobby hobby) { + return new HobbyPagingResponse( + hobby.getId(), + hobby.getName(), + hobby.getCode() + ); + } +} diff --git a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyResponse.java b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyResponse.java deleted file mode 100644 index cb17d259..00000000 --- a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbyResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.atwoz.member.infrastructure.member.profile.hobby.dto; - -import com.atwoz.member.domain.member.profile.Hobby; -import lombok.Builder; - -@Builder -public record HobbyResponse( - String name, - String code -) { - - public static HobbyResponse from(final Hobby hobby) { - return HobbyResponse.builder() - .name(hobby.getName()) - .code(hobby.getCode()) - .build(); - } -} diff --git a/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbySingleResponse.java b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbySingleResponse.java new file mode 100644 index 00000000..dd0e58ac --- /dev/null +++ b/src/main/java/com/atwoz/member/infrastructure/member/profile/hobby/dto/HobbySingleResponse.java @@ -0,0 +1,16 @@ +package com.atwoz.member.infrastructure.member.profile.hobby.dto; + +import com.atwoz.member.domain.member.profile.Hobby; + +public record HobbySingleResponse( + String name, + String code +) { + + public static HobbySingleResponse from(final Hobby hobby) { + return new HobbySingleResponse( + hobby.getName(), + hobby.getCode() + ); + } +} diff --git a/src/main/java/com/atwoz/member/ui/member/profile/hobby/HobbyController.java b/src/main/java/com/atwoz/member/ui/member/profile/hobby/HobbyController.java index 393768ba..179ca44e 100644 --- a/src/main/java/com/atwoz/member/ui/member/profile/hobby/HobbyController.java +++ b/src/main/java/com/atwoz/member/ui/member/profile/hobby/HobbyController.java @@ -3,9 +3,9 @@ import com.atwoz.member.application.member.profile.hobby.HobbyQueryService; import com.atwoz.member.application.member.profile.hobby.HobbyService; import com.atwoz.member.application.member.profile.hobby.dto.HobbyCreateRequest; -import com.atwoz.member.application.member.profile.hobby.dto.HobbyResponses; +import com.atwoz.member.application.member.profile.hobby.dto.HobbyPagingResponses; import com.atwoz.member.application.member.profile.hobby.dto.HobbyUpdateRequest; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbySingleResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; @@ -36,12 +36,12 @@ public ResponseEntity saveHobby(@RequestBody @Valid final HobbyCreateReque } @GetMapping("/{hobbyId}") - public ResponseEntity findHobby(@PathVariable("hobbyId") final Long hobbyId) { + public ResponseEntity findHobby(@PathVariable("hobbyId") final Long hobbyId) { return ResponseEntity.ok(hobbyQueryService.findHobby(hobbyId)); } @GetMapping - public ResponseEntity findHobbiesWithPaging(@PageableDefault(sort = "id") final Pageable pageable) { + public ResponseEntity findHobbiesWithPaging(@PageableDefault(sort = "id") final Pageable pageable) { return ResponseEntity.ok(hobbyQueryService.findHobbiesWithPaging(pageable)); } From c10a0b8ee4bda90e8afcb3eeb533ae5da1992c49 Mon Sep 17 00:00:00 2001 From: eom-tae-in Date: Wed, 25 Sep 2024 19:30:14 +0900 Subject: [PATCH 05/11] =?UTF-8?q?test:=20=EC=B7=A8=EB=AF=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=95=20api=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B8=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/hobby/HobbyQueryServiceTest.java | 34 +++++----- .../dto/response/HobbyResponseFixture.java | 25 ------- .../dto/response/HobbyResponsesFixture.java | 24 ------- ...\355\224\275\354\212\244\354\262\230.java" | 68 +++++++++++++++++++ .../profile/hobby/HobbyFakeRepository.java | 10 +-- .../hobby/HobbyQueryRepositoryTest.java | 14 ++-- .../HobbyControllerAcceptanceTestFixture.java | 20 +++--- .../hobby/HobbyControllerWebMvcTest.java | 23 ++++--- 8 files changed, 121 insertions(+), 97 deletions(-) delete mode 100644 src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponseFixture.java delete mode 100644 src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponsesFixture.java create mode 100644 "src/test/java/com/atwoz/member/fixture/member/dto/response/hobby/\354\267\250\353\257\270_\354\235\221\353\213\265_\355\224\275\354\212\244\354\262\230.java" diff --git a/src/test/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryServiceTest.java b/src/test/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryServiceTest.java index f798e5eb..f0ab793a 100644 --- a/src/test/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryServiceTest.java +++ b/src/test/java/com/atwoz/member/application/member/profile/hobby/HobbyQueryServiceTest.java @@ -1,11 +1,12 @@ package com.atwoz.member.application.member.profile.hobby; -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.HobbyFakeRepository; -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 org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; @@ -15,7 +16,8 @@ import org.springframework.data.domain.Pageable; import static com.atwoz.member.fixture.member.domain.HobbyFixture.취미_생성; -import static com.atwoz.member.fixture.member.dto.response.HobbyResponseFixture.취미_응답_생성_취미; +import static com.atwoz.member.fixture.member.dto.response.hobby.취미_응답_픽스처.취미_단건_조회_응답_픽스처.취미_단건_조회_응답_생성_취미; +import static com.atwoz.member.fixture.member.dto.response.hobby.취미_응답_픽스처.취미_페이징_조회_응답_픽스처.취미_페이징_조회_응답_생성_취미; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; @@ -43,12 +45,12 @@ class 취미_조회 { Long hobbyId = savedHobby.getId(); // when - HobbyResponse hobbyResponse = hobbyQueryService.findHobby(hobbyId); + HobbySingleResponse response = hobbyQueryService.findHobby(hobbyId); // then - HobbyResponse expectedHobbyResponse = 취미_응답_생성_취미(savedHobby); - assertThat(hobbyResponse).usingRecursiveComparison() - .isEqualTo(expectedHobbyResponse); + HobbySingleResponse expectedResponse = 취미_단건_조회_응답_생성_취미(savedHobby); + assertThat(response).usingRecursiveComparison() + .isEqualTo(expectedResponse); } @Test @@ -69,19 +71,19 @@ class 취미_조회 { Pageable pageable = PageRequest.of(0, 10); // when - HobbyResponses hobbyResponses = hobbyQueryService.findHobbiesWithPaging(pageable); + HobbyPagingResponses hobbyPagingResponses = hobbyQueryService.findHobbiesWithPaging(pageable); // then assertSoftly(softly -> { - softly.assertThat(hobbyResponses.nowPage()).isEqualTo(0); - softly.assertThat(hobbyResponses.nextPage()).isEqualTo(-1); - softly.assertThat(hobbyResponses.totalPages()).isEqualTo(1); - softly.assertThat(hobbyResponses.totalElements()).isEqualTo(1); - HobbyResponse hobbyResponse = hobbyResponses.hobbyResponses().get(0); - HobbyResponse expectedHobbyResponse = 취미_응답_생성_취미(savedHobby); - softly.assertThat(hobbyResponse) + softly.assertThat(hobbyPagingResponses.nowPage()).isEqualTo(0); + softly.assertThat(hobbyPagingResponses.nextPage()).isEqualTo(-1); + softly.assertThat(hobbyPagingResponses.totalPages()).isEqualTo(1); + softly.assertThat(hobbyPagingResponses.totalElements()).isEqualTo(1); + HobbyPagingResponse hobbyPagingResponse = hobbyPagingResponses.hobbyPagingResponses().get(0); + HobbyPagingResponse expectedResponse = 취미_페이징_조회_응답_생성_취미(savedHobby); + softly.assertThat(hobbyPagingResponse) .usingRecursiveComparison() - .isEqualTo(expectedHobbyResponse); + .isEqualTo(expectedResponse); }); } } diff --git a/src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponseFixture.java b/src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponseFixture.java deleted file mode 100644 index ca9ebff4..00000000 --- a/src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponseFixture.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.atwoz.member.fixture.member.dto.response; - -import com.atwoz.member.domain.member.profile.Hobby; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; - -@SuppressWarnings("NonAsciiCharacters") -public class HobbyResponseFixture { - - private static final String DEFAULT_HOBBY_NAME = "hobby"; - private static final String DEFAULT_HOBBY_CODE = "code"; - - public static HobbyResponse 취미_응답_생성() { - return HobbyResponse.builder() - .name(DEFAULT_HOBBY_NAME) - .code(DEFAULT_HOBBY_CODE) - .build(); - } - - public static HobbyResponse 취미_응답_생성_취미(final Hobby hobby) { - return HobbyResponse.builder() - .name(hobby.getName()) - .code(hobby.getCode()) - .build(); - } -} diff --git a/src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponsesFixture.java b/src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponsesFixture.java deleted file mode 100644 index 5baa4abd..00000000 --- a/src/test/java/com/atwoz/member/fixture/member/dto/response/HobbyResponsesFixture.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.atwoz.member.fixture.member.dto.response; - -import com.atwoz.member.application.member.profile.hobby.dto.HobbyResponses; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; -import java.util.List; - -@SuppressWarnings("NonAsciiCharacters") -public class HobbyResponsesFixture { - - private static final int DEFAULT_NOW_PAGE = 0; - private static final int DEFAULT_NEXT_PAGE = 1; - private static final int DEFAULT_TOTAL_PAGES = 2; - private static final long DEFAULT_TOTAL_ELEMENTS = 3; - - public static HobbyResponses 취미_응답_목록_생성_취미응답목록(final List hobbyResponses) { - return HobbyResponses.builder() - .hobbyResponses(hobbyResponses) - .nowPage(DEFAULT_NOW_PAGE) - .nextPage(DEFAULT_NEXT_PAGE) - .totalPages(DEFAULT_TOTAL_PAGES) - .totalElements(DEFAULT_TOTAL_ELEMENTS) - .build(); - } -} diff --git "a/src/test/java/com/atwoz/member/fixture/member/dto/response/hobby/\354\267\250\353\257\270_\354\235\221\353\213\265_\355\224\275\354\212\244\354\262\230.java" "b/src/test/java/com/atwoz/member/fixture/member/dto/response/hobby/\354\267\250\353\257\270_\354\235\221\353\213\265_\355\224\275\354\212\244\354\262\230.java" new file mode 100644 index 00000000..2bc681a4 --- /dev/null +++ "b/src/test/java/com/atwoz/member/fixture/member/dto/response/hobby/\354\267\250\353\257\270_\354\235\221\353\213\265_\355\224\275\354\212\244\354\262\230.java" @@ -0,0 +1,68 @@ +package com.atwoz.member.fixture.member.dto.response.hobby; + +import com.atwoz.member.application.member.profile.hobby.dto.HobbyPagingResponses; +import com.atwoz.member.domain.member.profile.Hobby; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbySingleResponse; +import java.util.List; + +@SuppressWarnings("NonAsciiCharacters") +public class 취미_응답_픽스처 { + + public static class 취미_페이징_조회_응답_픽스처 { + + private static final long DEFAULT_HOBBY_ID = 1L; + private static final String DEFAULT_HOBBY_NAME = "hobby"; + private static final String DEFAULT_HOBBY_CODE = "code"; + private static final int DEFAULT_NOW_PAGE = 0; + private static final int DEFAULT_NEXT_PAGE = 1; + private static final int DEFAULT_TOTAL_PAGES = 2; + private static final long DEFAULT_TOTAL_ELEMENTS = 3; + + public static HobbyPagingResponse 취미_페이징_조회_응답_생성() { + return new HobbyPagingResponse( + DEFAULT_HOBBY_ID, + DEFAULT_HOBBY_NAME, + DEFAULT_HOBBY_CODE + ); + } + + public static HobbyPagingResponse 취미_페이징_조회_응답_생성_취미(final Hobby hobby) { + return new HobbyPagingResponse( + hobby.getId(), + hobby.getName(), + hobby.getCode() + ); + } + + public static HobbyPagingResponses 취미_페이징_조회_목록_응답_생성_취미페이징목록응답(final List responses) { + return HobbyPagingResponses.builder() + .hobbyPagingResponses(responses) + .nowPage(DEFAULT_NOW_PAGE) + .nextPage(DEFAULT_NEXT_PAGE) + .totalPages(DEFAULT_TOTAL_PAGES) + .totalElements(DEFAULT_TOTAL_ELEMENTS) + .build(); + } + } + + public static class 취미_단건_조회_응답_픽스처 { + + private static final String DEFAULT_HOBBY_NAME = "hobby"; + private static final String DEFAULT_HOBBY_CODE = "code"; + + public static HobbySingleResponse 취미_단건_조회_응답_생성() { + return new HobbySingleResponse( + DEFAULT_HOBBY_NAME, + DEFAULT_HOBBY_CODE + ); + } + + public static HobbySingleResponse 취미_단건_조회_응답_생성_취미(final Hobby hobby) { + return new HobbySingleResponse( + hobby.getName(), + hobby.getCode() + ); + } + } +} diff --git a/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyFakeRepository.java b/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyFakeRepository.java index 86e6231d..166c0948 100644 --- a/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyFakeRepository.java +++ b/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyFakeRepository.java @@ -2,7 +2,7 @@ import com.atwoz.member.domain.member.profile.Hobby; import com.atwoz.member.domain.member.profile.HobbyRepository; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -51,16 +51,16 @@ public Optional findHobbyByCode(final String hobbyCode) { } @Override - public Page findHobbiesWithPaging(final Pageable pageable) { - List hobbyResponses = map.values() + public Page findHobbiesWithPaging(final Pageable pageable) { + List hobbyPagingRespons = map.values() .stream() .sorted(Comparator.comparing(Hobby::getId)) .skip(pageable.getOffset()) .limit(pageable.getPageSize()) - .map(HobbyResponse::from) + .map(HobbyPagingResponse::from) .toList(); - return new PageImpl<>(hobbyResponses); + return new PageImpl<>(hobbyPagingRespons); } @Override diff --git a/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepositoryTest.java b/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepositoryTest.java index a46b89b7..a20978ea 100644 --- a/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepositoryTest.java +++ b/src/test/java/com/atwoz/member/infrastructure/member/profile/hobby/HobbyQueryRepositoryTest.java @@ -3,7 +3,7 @@ import com.atwoz.helper.IntegrationHelper; import com.atwoz.member.domain.member.profile.Hobby; import com.atwoz.member.domain.member.profile.HobbyRepository; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; @@ -17,7 +17,7 @@ import org.springframework.data.domain.Pageable; import static com.atwoz.member.fixture.member.domain.HobbyFixture.취미_생성_이름_코드; -import static com.atwoz.member.fixture.member.dto.response.HobbyResponseFixture.취미_응답_생성_취미; +import static com.atwoz.member.fixture.member.dto.response.hobby.취미_응답_픽스처.취미_페이징_조회_응답_픽스처.취미_페이징_조회_응답_생성_취미; import static org.assertj.core.api.SoftAssertions.assertSoftly; @DisplayNameGeneration(ReplaceUnderscores.class) @@ -43,10 +43,10 @@ void setup() { Pageable pageable = PageRequest.of(0, 10); // when - Page result = hobbyQueryRepository.findHobbiesWithPaging(pageable); + Page result = hobbyQueryRepository.findHobbiesWithPaging(pageable); // then - List hobbyResponses = result.getContent(); + List hobbyPagingRespons = result.getContent(); assertSoftly(softly -> { softly.assertThat(result.hasNext()).isTrue(); softly.assertThat(result.getTotalElements()).isEqualTo(15); @@ -55,10 +55,10 @@ void setup() { softly.assertThat(result).hasSize(10); IntStream.range(0, 10) .forEach(index -> { - HobbyResponse hobbyResponse = hobbyResponses.get(index); - softly.assertThat(hobbyResponse) + HobbyPagingResponse hobbyPagingResponse = hobbyPagingRespons.get(index); + softly.assertThat(hobbyPagingResponse) .usingRecursiveComparison() - .isEqualTo(취미_응답_생성_취미(hobbies.get(index))); + .isEqualTo(취미_페이징_조회_응답_생성_취미(hobbies.get(index))); }); }); } diff --git a/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerAcceptanceTestFixture.java b/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerAcceptanceTestFixture.java index 0813bd76..463a00b8 100644 --- a/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerAcceptanceTestFixture.java +++ b/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerAcceptanceTestFixture.java @@ -3,7 +3,7 @@ import com.atwoz.admin.application.auth.AdminAccessTokenProvider; import com.atwoz.helper.IntegrationHelper; import com.atwoz.member.application.member.profile.hobby.dto.HobbyCreateRequest; -import com.atwoz.member.application.member.profile.hobby.dto.HobbyResponses; +import com.atwoz.member.application.member.profile.hobby.dto.HobbyPagingResponses; import com.atwoz.member.application.member.profile.hobby.dto.HobbyUpdateRequest; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.MemberRepository; @@ -11,7 +11,7 @@ import com.atwoz.member.domain.member.profile.HobbyRepository; import com.atwoz.member.domain.member.profile.Style; import com.atwoz.member.domain.member.profile.StyleRepository; -import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyResponse; +import com.atwoz.member.infrastructure.member.profile.hobby.dto.HobbyPagingResponse; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.response.ExtractableResponse; @@ -95,11 +95,11 @@ void init() { } protected void 취미_단건_조회_요청_검증(final ExtractableResponse response) { - HobbyResponse hobbyResponse = response.as(HobbyResponse.class); + HobbyPagingResponse hobbyPagingResponse = response.as(HobbyPagingResponse.class); assertSoftly(softly -> { softly.assertThat(response.statusCode()).isEqualTo(HttpStatus.SC_OK); - softly.assertThat(hobbyResponse.name()).isEqualTo("hobby1"); - softly.assertThat(hobbyResponse.code()).isEqualTo("code1"); + softly.assertThat(hobbyPagingResponse.name()).isEqualTo("hobby1"); + softly.assertThat(hobbyPagingResponse.code()).isEqualTo("code1"); }); } @@ -115,13 +115,13 @@ void init() { } protected void 취미_페이징_조회_요청_검증(final ExtractableResponse response) { - HobbyResponses hobbyResponses = response.as(HobbyResponses.class); + HobbyPagingResponses hobbyPagingResponses = response.as(HobbyPagingResponses.class); assertSoftly(softly -> { softly.assertThat(response.statusCode()).isEqualTo(HttpStatus.SC_OK); - softly.assertThat(hobbyResponses.nowPage()).isEqualTo(0); - softly.assertThat(hobbyResponses.nextPage()).isEqualTo(-1); - softly.assertThat(hobbyResponses.totalPages()).isEqualTo(1); - softly.assertThat(hobbyResponses.totalElements()).isEqualTo(1); + softly.assertThat(hobbyPagingResponses.nowPage()).isEqualTo(0); + softly.assertThat(hobbyPagingResponses.nextPage()).isEqualTo(-1); + softly.assertThat(hobbyPagingResponses.totalPages()).isEqualTo(1); + softly.assertThat(hobbyPagingResponses.totalElements()).isEqualTo(1); }); } diff --git a/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerWebMvcTest.java b/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerWebMvcTest.java index 3a2042c6..a419b8bd 100644 --- a/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerWebMvcTest.java +++ b/src/test/java/com/atwoz/member/ui/member/profile/hobby/HobbyControllerWebMvcTest.java @@ -3,7 +3,8 @@ import com.atwoz.helper.MockBeanInjection; import com.atwoz.member.application.member.profile.hobby.dto.HobbyCreateRequest; import com.atwoz.member.application.member.profile.hobby.dto.HobbyUpdateRequest; -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 com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration; @@ -18,8 +19,9 @@ import static com.atwoz.helper.RestDocsHelper.customDocument; import static com.atwoz.member.fixture.member.dto.request.HobbyCreateRequestFixture.취미_생성_요청_생성; import static com.atwoz.member.fixture.member.dto.request.HobbyUpdateRequestFixture.취미_업데이트_요청_생성; -import static com.atwoz.member.fixture.member.dto.response.HobbyResponseFixture.취미_응답_생성; -import static com.atwoz.member.fixture.member.dto.response.HobbyResponsesFixture.취미_응답_목록_생성_취미응답목록; +import static com.atwoz.member.fixture.member.dto.response.hobby.취미_응답_픽스처.취미_단건_조회_응답_픽스처.취미_단건_조회_응답_생성; +import static com.atwoz.member.fixture.member.dto.response.hobby.취미_응답_픽스처.취미_페이징_조회_응답_픽스처.취미_페이징_조회_목록_응답_생성_취미페이징목록응답; +import static com.atwoz.member.fixture.member.dto.response.hobby.취미_응답_픽스처.취미_페이징_조회_응답_픽스처.취미_페이징_조회_응답_생성; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.doNothing; @@ -83,8 +85,8 @@ class HobbyControllerWebMvcTest extends MockBeanInjection { void 취미를_단건_조회한다() throws Exception { // given Long hobbyId = 1L; - HobbyResponse hobbyResponse = 취미_응답_생성(); - when(hobbyQueryService.findHobby(anyLong())).thenReturn(hobbyResponse); + HobbySingleResponse hobbySingleResponse = 취미_단건_조회_응답_생성(); + when(hobbyQueryService.findHobby(anyLong())).thenReturn(hobbySingleResponse); // when mockMvc.perform(get("/api/members/hobbies/{hobbyId}", hobbyId) @@ -107,9 +109,9 @@ class HobbyControllerWebMvcTest extends MockBeanInjection { @Test void 취미를_페이징_조회한다() throws Exception { // given - List hobbyResponses = List.of(취미_응답_생성()); + List hobbyPagingResponse = List.of(취미_페이징_조회_응답_생성()); when(hobbyQueryService.findHobbiesWithPaging(any(Pageable.class))) - .thenReturn(취미_응답_목록_생성_취미응답목록(hobbyResponses)); + .thenReturn(취미_페이징_조회_목록_응답_생성_취미페이징목록응답(hobbyPagingResponse)); // when & then mockMvc.perform(get("/api/members/hobbies") @@ -126,9 +128,10 @@ class HobbyControllerWebMvcTest extends MockBeanInjection { partWithName("size").description("조회되는 데이터 수, 한 페이지당 조회되는 데이터 수입니다.").optional() ), responseFields( - fieldWithPath("hobbyResponses").description("조회된 취미 목록"), - fieldWithPath("hobbyResponses[].name").description("조회된 취미의 이름"), - fieldWithPath("hobbyResponses[].code").description("조회된 취미의 코드"), + fieldWithPath("hobbyPagingResponses").description("취미 페이징 조회 결과 목록"), + fieldWithPath("hobbyPagingResponses[].hobbyId").description("조회된 취미의 id"), + fieldWithPath("hobbyPagingResponses[].name").description("조회된 취미의 이름"), + fieldWithPath("hobbyPagingResponses[].code").description("조회된 취미의 코드"), fieldWithPath("nowPage").description("현재 페이지"), fieldWithPath("nextPage").description("다음 페이지, 다음 페이지가 없을 경우 -1을 반환합니다."), fieldWithPath("totalPages").description("전체 페이지 수"), From c253be99f9400c9a50974a3e6656b306948a4fad Mon Sep 17 00:00:00 2001 From: eom-tae-in Date: Wed, 25 Sep 2024 19:52:45 +0900 Subject: [PATCH 06/11] =?UTF-8?q?refactor:=20=EC=8A=A4=ED=83=80=EC=9D=BC?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=95=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EB=90=9C=20=EC=8A=A4=ED=83=80=EC=9D=BC?= =?UTF-8?q?=EC=9D=98=20id=20=EC=A0=95=EB=B3=B4=EB=8F=84=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/style/StyleQueryService.java | 17 +++++++++-------- ...esponses.java => StylePagingResponses.java} | 14 +++++++------- .../domain/member/profile/StyleRepository.java | 4 ++-- .../profile/style/StyleQueryRepository.java | 9 +++++---- .../profile/style/StyleRepositoryImpl.java | 4 ++-- .../profile/style/dto/StylePagingResponse.java | 18 ++++++++++++++++++ .../profile/style/dto/StyleResponse.java | 18 ------------------ .../profile/style/dto/StyleSingleResponse.java | 16 ++++++++++++++++ .../member/profile/style/StyleController.java | 8 ++++---- 9 files changed, 63 insertions(+), 45 deletions(-) rename src/main/java/com/atwoz/member/application/member/profile/style/dto/{StyleResponses.java => StylePagingResponses.java} (70%) create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/profile/style/dto/StylePagingResponse.java delete mode 100644 src/main/java/com/atwoz/member/infrastructure/member/profile/style/dto/StyleResponse.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/member/profile/style/dto/StyleSingleResponse.java 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/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