From a81b9edd10e0b3d580d7a9c5eaf5601cf346fb91 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0N7JBUG\\user" Date: Mon, 20 Jan 2025 18:44:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=EC=82=AC=EC=9D=B4=ED=8A=B8=20API=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../imdang/domain/exception/ErrorCode.java | 9 +++- .../com/project/imdang/saga/SagaStep.java | 4 +- .../application/rest/MyInsightController.java | 23 +++++++- .../rest/MyInsightControllerTest.java | 12 +++++ .../domain/InsightApplicationServiceImpl.java | 17 ++++-- .../insight/detail/DetailInsightResponse.java | 6 +++ .../insight/list/InsightSimpleResponse.java | 21 ++++++++ .../list/ListMyInsightCreatedByMeQuery.java | 24 +++++++++ .../domain/handler/ExchangeRequestHelper.java | 4 ++ .../ExchangeRequestMemberCouponSaga.java | 44 ++++++---------- .../handler/InsightAccuseMemberSaga.java | 9 ++-- .../AcceptExchangeCommandHandler.java | 43 ++++++++------- .../RequestExchangeCommandHandler.java | 6 +-- .../insight/DetailInsightCommandHandler.java | 8 +-- ...tmentComplexByDistrictCommandHandler.java} | 4 +- ...istMyInsightCreatedByMeCommandHandler.java | 52 +++++++++++++++++++ .../domain/mapper/InsightDataMapper.java | 7 +-- .../domain/mapper/SnapshotDataMapper.java | 23 ++++++-- .../service/InsightApplicationService.java | 7 ++- .../repository/MemberSnapshotRepository.java | 2 + .../adapter/MemberSnapshotRepositoryImpl.java | 6 +++ .../MemberSnapshotJpaRepository.java | 7 +++ 22 files changed, 258 insertions(+), 80 deletions(-) create mode 100644 insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/InsightSimpleResponse.java create mode 100644 insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightCreatedByMeQuery.java rename insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/{ListApartmentComplexByDistrictCommandHandler.java => ListMyInsightApartmentComplexByDistrictCommandHandler.java} (87%) create mode 100644 insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCreatedByMeCommandHandler.java diff --git a/common/common-domain/common-domain-core/src/main/java/com/project/imdang/domain/exception/ErrorCode.java b/common/common-domain/common-domain-core/src/main/java/com/project/imdang/domain/exception/ErrorCode.java index 55da8246..ab68689a 100644 --- a/common/common-domain/common-domain-core/src/main/java/com/project/imdang/domain/exception/ErrorCode.java +++ b/common/common-domain/common-domain-core/src/main/java/com/project/imdang/domain/exception/ErrorCode.java @@ -5,5 +5,12 @@ public enum ErrorCode { MEMBER_15ACCUSED, ALREADY_ACCUSED, ALREADY_RECOMMENDED, - EXCHANGE_REQUIRED + EXCHANGE_REQUIRED, + + // 요청 실패 + EXCHANGE_REQUEST_FAILED, + // 요청 수락 실패 + EXCHANGE_REQUEST_ACCEPT_FAILED, + // 요청 거절 실패 + EXCHANGE_REQUEST_REJECT_FAILED } diff --git a/infrastructure/saga/src/main/java/com/project/imdang/saga/SagaStep.java b/infrastructure/saga/src/main/java/com/project/imdang/saga/SagaStep.java index 17d418b6..2b631b1f 100644 --- a/infrastructure/saga/src/main/java/com/project/imdang/saga/SagaStep.java +++ b/infrastructure/saga/src/main/java/com/project/imdang/saga/SagaStep.java @@ -2,7 +2,7 @@ import com.project.imdang.domain.event.DomainEvent; -public interface SagaStep { +public interface SagaStep { S process(T data); - U rollback(T data); + void rollback(T data); } diff --git a/insight-service/insight-application/src/main/java/com/project/imdang/insight/service/application/rest/MyInsightController.java b/insight-service/insight-application/src/main/java/com/project/imdang/insight/service/application/rest/MyInsightController.java index edb11047..24793acc 100644 --- a/insight-service/insight-application/src/main/java/com/project/imdang/insight/service/application/rest/MyInsightController.java +++ b/insight-service/insight-application/src/main/java/com/project/imdang/insight/service/application/rest/MyInsightController.java @@ -3,6 +3,8 @@ import com.project.imdang.insight.service.domain.dto.insight.list.ApartmentComplexResponse; import com.project.imdang.insight.service.domain.dto.insight.list.DistrictResponse; import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.InsightSimpleResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightCreatedByMeQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightQuery; import com.project.imdang.insight.service.domain.ports.input.service.InsightApplicationService; import com.project.imdang.insight.service.domain.valueobject.District; @@ -45,7 +47,7 @@ public ResponseEntity> listDistrict(@AuthenticationPrinci @GetMapping("/by-district/apartment-complexes") public ResponseEntity> listApartmentComplexByDistrict(@AuthenticationPrincipal UUID memberId, @ModelAttribute District district) { - List apartmentComplexResponses = insightApplicationService.listApartmentComplexByDistrict(memberId, district); + List apartmentComplexResponses = insightApplicationService.listMyInsightApartmentComplexByDistrict(memberId, district); return ResponseEntity.ok(apartmentComplexResponses); } @@ -76,4 +78,23 @@ public ResponseEntity> list(@AuthenticationPrincipal UUID Page insights = insightApplicationService.listMyInsight(listMyInsightQuery); return ResponseEntity.ok(insights); } + + @GetMapping("/created-by-me") + public ResponseEntity> listCreatedByMe(@AuthenticationPrincipal UUID memberId, + // TODO - PagingQuery + @RequestParam(name = "pageNumber", defaultValue = "0") Integer pageNumber, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + @RequestParam(name = "direction", defaultValue = "DESC") String direction, + @RequestParam(name = "properties", defaultValue = "created_at") String[] properties) { + + ListMyInsightCreatedByMeQuery listMyInsightCreatedByMeQuery = ListMyInsightCreatedByMeQuery.builder() + .memberId(memberId) + .pageNumber(pageNumber) + .pageSize(pageSize) + .direction(direction) + .properties(properties) + .build(); + Page insights = insightApplicationService.listMyInsightCreatedByMe(listMyInsightCreatedByMeQuery); + return ResponseEntity.ok(insights); + } } diff --git a/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/MyInsightControllerTest.java b/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/MyInsightControllerTest.java index dc53f5f4..64ff0f80 100644 --- a/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/MyInsightControllerTest.java +++ b/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/MyInsightControllerTest.java @@ -85,4 +85,16 @@ void list() throws Exception { .andDo(print()) .andReturn(); } + + @Test + void listCreatedByMe() throws Exception { + mockMvc.perform(get("/my-insights/created-by-me") + .header("Authorization", "Bearer " + requestMemberToken) + .param("pageNumber", "1") + .param("pageSize", "5") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andDo(print()) + .andReturn(); + } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/InsightApplicationServiceImpl.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/InsightApplicationServiceImpl.java index 32cf55af..511caae7 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/InsightApplicationServiceImpl.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/InsightApplicationServiceImpl.java @@ -11,8 +11,10 @@ import com.project.imdang.insight.service.domain.dto.insight.list.ApartmentComplexResponse; import com.project.imdang.insight.service.domain.dto.insight.list.DistrictResponse; import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.InsightSimpleResponse; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightByApartmentComplexQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightQuery; +import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightCreatedByMeQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightQuery; import com.project.imdang.insight.service.domain.dto.insight.recommend.RecommendInsightCommand; import com.project.imdang.insight.service.domain.dto.insight.recommend.RecommendInsightResponse; @@ -22,10 +24,11 @@ import com.project.imdang.insight.service.domain.handler.insight.CreateInsightCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.DeleteInsightCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.DetailInsightCommandHandler; -import com.project.imdang.insight.service.domain.handler.insight.ListApartmentComplexByDistrictCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListInsightByApartmentComplexCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListInsightCommandHandler; +import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightApartmentComplexByDistrictCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightCommandHandler; +import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightCreatedByMeCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightDistrictCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListMyVisitedApartmentComplexCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.RecommendInsightCommandHandler; @@ -52,8 +55,9 @@ public class InsightApplicationServiceImpl implements InsightApplicationService private final ListMyInsightDistrictCommandHandler listMyInsightDistrictCommandHandler; - private final ListApartmentComplexByDistrictCommandHandler listApartmentComplexByDistrictCommandHandler; + private final ListMyInsightApartmentComplexByDistrictCommandHandler listMyInsightApartmentComplexByDistrictCommandHandler; private final ListMyInsightCommandHandler listMyInsightCommandHandler; + private final ListMyInsightCreatedByMeCommandHandler listMyInsightCreatedByMeCommandHandler; private final DetailInsightCommandHandler detailInsightCommandHandler; private final CreateInsightCommandHandler createInsightCommandHandler; @@ -84,8 +88,8 @@ public List listMyInsightDistrict(UUID memberId) { } @Override - public List listApartmentComplexByDistrict(UUID memberId, District district) { - return listApartmentComplexByDistrictCommandHandler.listApartmentComplexByDistrict(memberId, district); + public List listMyInsightApartmentComplexByDistrict(UUID memberId, District district) { + return listMyInsightApartmentComplexByDistrictCommandHandler.listMyInsightApartmentComplexByDistrict(memberId, district); } @Override @@ -93,6 +97,11 @@ public Page listMyInsight(ListMyInsightQuery listMyInsightQuery return listMyInsightCommandHandler.listMyInsight(listMyInsightQuery); } + @Override + public Page listMyInsightCreatedByMe(ListMyInsightCreatedByMeQuery listMyInsightCreatedByMeQuery) { + return listMyInsightCreatedByMeCommandHandler.listMyInsightCreatedByMe(listMyInsightCreatedByMeQuery); + } + @Override public DetailInsightResponse detailInsight(DetailInsightQuery detailInsightQuery) { return detailInsightCommandHandler.detailInsight(detailInsightQuery); diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/detail/DetailInsightResponse.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/detail/DetailInsightResponse.java index e9e5dcf8..0048cdaa 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/detail/DetailInsightResponse.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/detail/DetailInsightResponse.java @@ -56,6 +56,7 @@ public class DetailInsightResponse { private Integer score; private ZonedDateTime createdAt; private ExchangeRequestStatus exchangeRequestStatus; + private UUID exchangeRequestId; public DetailInsightResponse toPreviewInsightResponse() { return DetailInsightResponse.builder() @@ -65,6 +66,11 @@ public DetailInsightResponse toPreviewInsightResponse() { .title(title) .address(address) .apartmentComplex(apartmentComplex) + .visitAt(visitAt) + .visitTimes(visitTimes) + .visitMethods(visitMethods) + .access(access) + .summary(summary) .recommendedCount(recommendedCount) .memberId(memberId) // .member(member) diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/InsightSimpleResponse.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/InsightSimpleResponse.java new file mode 100644 index 00000000..b8c10d4c --- /dev/null +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/InsightSimpleResponse.java @@ -0,0 +1,21 @@ +package com.project.imdang.insight.service.domain.dto.insight.list; + +import com.project.imdang.insight.service.domain.valueobject.Address; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class InsightSimpleResponse { + private UUID insightId; + private Integer recommendedCount; + private Address address; + private String title; +} diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightCreatedByMeQuery.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightCreatedByMeQuery.java new file mode 100644 index 00000000..1475f405 --- /dev/null +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightCreatedByMeQuery.java @@ -0,0 +1,24 @@ +package com.project.imdang.insight.service.domain.dto.insight.list; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class ListMyInsightCreatedByMeQuery { + // extends PagingQuery { +// @Setter + private UUID memberId; + + private Integer pageNumber; + private Integer pageSize; + private String direction; + private String[] properties; +} diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestHelper.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestHelper.java index 89b36ad5..c484a3fe 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestHelper.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestHelper.java @@ -31,4 +31,8 @@ public ExchangeRequest save(ExchangeRequest exchangeRequest) { log.info("ExchangeRequest[id: {}] is saved.", savedExchangeRequest.getId().getValue()); return savedExchangeRequest; } + + public void delete(ExchangeRequestId exchangeRequestId) { + exchangeRequestRepository.deleteById(exchangeRequestId); + } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestMemberCouponSaga.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestMemberCouponSaga.java index ee21dd98..5df8aef6 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestMemberCouponSaga.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/ExchangeRequestMemberCouponSaga.java @@ -1,65 +1,51 @@ package com.project.imdang.insight.service.domain.handler; -import com.project.imdang.domain.event.EmptyEvent; import com.project.imdang.domain.message.MemberCouponPendingUpdatedResponseMessage; import com.project.imdang.domain.valueobject.ExchangeRequestId; import com.project.imdang.insight.service.domain.ExchangeDomainService; import com.project.imdang.insight.service.domain.entity.ExchangeRequest; import com.project.imdang.insight.service.domain.event.ExchangeRequestCreatedEvent; -import com.project.imdang.insight.service.domain.exception.ExchangeDomainException; -import com.project.imdang.insight.service.domain.exception.ExchangeRequestNotFoundException; -import com.project.imdang.insight.service.domain.ports.output.repository.ExchangeRequestRepository; +import com.project.imdang.insight.service.domain.exception.InsightApplicationServiceException; import com.project.imdang.saga.SagaStep; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import static com.project.imdang.domain.exception.ErrorCode.EXCHANGE_REQUEST_FAILED; + @Slf4j @RequiredArgsConstructor @Component -public class ExchangeRequestMemberCouponSaga implements SagaStep { +public class ExchangeRequestMemberCouponSaga implements SagaStep { // request exchange using coupon // init exchange_request → memberCoupon "pending" → save exchange_request private final ExchangeDomainService exchangeDomainService; - private final ExchangeRequestRepository exchangeRequestRepository; - -// private final EventPublisher eventPublisher; + private final ExchangeRequestHelper exchangeRequestHelper; // memberCoupon "PENDING" 처리 완료 @Override public ExchangeRequestCreatedEvent process(MemberCouponPendingUpdatedResponseMessage response) { ExchangeRequestId exchangeRequestId = new ExchangeRequestId(response.getExchangeRequestId()); - ExchangeRequest exchangeRequest = exchangeRequestRepository.findById(exchangeRequestId) - .orElseThrow(() -> new ExchangeRequestNotFoundException(exchangeRequestId)); - log.info("MemberCoupon[id: {}] updated as PENDING.", exchangeRequest.getMemberCouponId()); + ExchangeRequest exchangeRequest = exchangeRequestHelper.get(exchangeRequestId); + log.info("MemberCoupon[id: {}] status updated as PENDING.", exchangeRequest.getMemberCouponId()); ExchangeRequestCreatedEvent exchangeRequestCreatedEvent = exchangeDomainService.completeCheckCoupon(exchangeRequest); - save(exchangeRequestCreatedEvent.getExchangeRequest()); + exchangeRequestHelper.save(exchangeRequestCreatedEvent.getExchangeRequest()); // eventPublisher.publish(exchangeRequestCreatedEvent); return exchangeRequestCreatedEvent; } // memberCoupon "PENDING" 처리 실패 @Override - public EmptyEvent rollback(MemberCouponPendingUpdatedResponseMessage response) { - ExchangeRequestId exchangeRequestId = new ExchangeRequestId(response.getExchangeRequestId()); - // TODO - 로그 - log.info("Failed!"); - // TODO - CHECK : 삭제 처리 - exchangeRequestRepository.deleteById(exchangeRequestId); - return EmptyEvent.INSTANCE; - } + public void rollback(MemberCouponPendingUpdatedResponseMessage response) { + + throw new InsightApplicationServiceException(EXCHANGE_REQUEST_FAILED); - private ExchangeRequest save(ExchangeRequest exchangeRequest) { - ExchangeRequest savedExchangeRequest = exchangeRequestRepository.save(exchangeRequest); - if(savedExchangeRequest == null) { - String errorMessage = "Could not save ExchangeRequest!"; - log.error(errorMessage); - throw new ExchangeDomainException(errorMessage); - } - log.info("ExchangeRequest[id: {}] is saved.", savedExchangeRequest.getId().getValue()); - return savedExchangeRequest; + // 삭제 처리 +// ExchangeRequestId exchangeRequestId = new ExchangeRequestId(response.getExchangeRequestId()); +// exchangeRequestHelper.delete(exchangeRequestId); +// return EmptyEvent.INSTANCE; } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/InsightAccuseMemberSaga.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/InsightAccuseMemberSaga.java index 81ceed22..997cd2b8 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/InsightAccuseMemberSaga.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/InsightAccuseMemberSaga.java @@ -12,20 +12,21 @@ @Slf4j @RequiredArgsConstructor @Component -public class InsightAccuseMemberSaga implements SagaStep { +public class InsightAccuseMemberSaga implements SagaStep { // insight accuse - // insight accuse → check accusedMember accusedCount & update status + // insight accuse → increase accusedMember accusedCount (& update status) private final InsightDomainService insightDomainService; + // accusedMember increase accusedCount 처리 완료 @Override public EmptyEvent process(MemberAccusedResponseMessage response) { InsightId accusedInsightId = new InsightId(response.getAccusedInsightId()); return null; } + // accusedMember increase accusedCount 처리 실패 @Override - public EmptyEvent rollback(MemberAccusedResponseMessage response) { - return null; + public void rollback(MemberAccusedResponseMessage response) { } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/AcceptExchangeCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/AcceptExchangeCommandHandler.java index 365b4f3d..4d526542 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/AcceptExchangeCommandHandler.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/AcceptExchangeCommandHandler.java @@ -1,6 +1,7 @@ package com.project.imdang.insight.service.domain.handler.exchange; import com.project.imdang.domain.valueobject.ExchangeRequestId; +import com.project.imdang.domain.valueobject.MemberCouponId; import com.project.imdang.insight.service.domain.ExchangeDomainService; import com.project.imdang.insight.service.domain.dto.exchange.accept.AcceptExchangeRequestCommand; import com.project.imdang.insight.service.domain.dto.exchange.accept.AcceptExchangeRequestResponse; @@ -36,24 +37,31 @@ public AcceptExchangeRequestResponse acceptExchangeRequest(AcceptExchangeRequest .equals(acceptExchangeRequestCommand.getRequestedMemberId())) { throw new RuntimeException(); } - ExchangeRequestAcceptedEvent exchangeRequestAcceptedEvent = exchangeDomainService.acceptExchangeRequest(exchangeRequest); - log.info("ExchangeRequest[id: {}] is accepted.", exchangeRequest.getId().getValue()); - ExchangeRequest saved = exchangeRequestHelper.save(exchangeRequest); - - // memberSnapshot에 insert - MemberSnapshot requestMemberSnapshot = MemberSnapshot.builder() - .memberId(exchangeRequest.getRequestMemberId()) - .snapshotId(exchangeRequest.getRequestedSnapshotId()) - .insightId(exchangeRequest.getRequestedInsightId()) - // TODO - CHECK - .createdAt(exchangeRequestAcceptedEvent.getCreatedAt()) - .build(); - memberSnapshotHelper.save(requestMemberSnapshot); if (exchangeRequest.getMemberCouponId() != null) { - // TODO : 쿠폰 사용 처리 + // 쿠폰 사용 처리 : 쿠폰 사용한 ExchangeRequest 수락 시, MemberCoupon 상태 'USED' 처리 + // 'USED' 처리 완료 - process + // 'USED' 처리 실패 - rollback + MemberCouponId memberCouponId = exchangeRequest.getMemberCouponId(); +// exchangeRequestAcceptedRequestMessagePublisher.publish( +// new ExchangeRequestAcceptedRequestMessage(exchangeRequest.getId().getValue())); } else { + + ExchangeRequestAcceptedEvent exchangeRequestAcceptedEvent = exchangeDomainService.acceptExchangeRequest(exchangeRequest); + log.info("ExchangeRequest[id: {}] is accepted.", exchangeRequest.getId().getValue()); + ExchangeRequest saved = exchangeRequestHelper.save(exchangeRequest); + + // memberSnapshot에 insert + MemberSnapshot requestMemberSnapshot = MemberSnapshot.builder() + .memberId(exchangeRequest.getRequestMemberId()) + .snapshotId(exchangeRequest.getRequestedSnapshotId()) + .insightId(exchangeRequest.getRequestedInsightId()) + // TODO - CHECK + .createdAt(exchangeRequestAcceptedEvent.getCreatedAt()) + .build(); + memberSnapshotHelper.save(requestMemberSnapshot); + MemberSnapshot requestedMemberSnapshot = MemberSnapshot.builder() .memberId(exchangeRequest.getRequestedMemberId()) .snapshotId(exchangeRequest.getRequestMemberSnapshotId()) @@ -63,10 +71,7 @@ public AcceptExchangeRequestResponse acceptExchangeRequest(AcceptExchangeRequest .build(); memberSnapshotHelper.save(requestedMemberSnapshot); } - - // TODO : publish - - - return exchangeRequestDataMapper.exchangeRequestToAcceptExchangeRequestResponse(saved); + return null; +// return exchangeRequestDataMapper.exchangeRequestToAcceptExchangeRequestResponse(saved); } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/RequestExchangeCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/RequestExchangeCommandHandler.java index 6abf0497..bde414d6 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/RequestExchangeCommandHandler.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/exchange/RequestExchangeCommandHandler.java @@ -12,7 +12,6 @@ import com.project.imdang.insight.service.domain.entity.ExchangeRequest; import com.project.imdang.insight.service.domain.entity.Snapshot; import com.project.imdang.insight.service.domain.event.ExchangeRequestCreatedEvent; -import com.project.imdang.insight.service.domain.exception.InsightApplicationServiceException; import com.project.imdang.insight.service.domain.exception.SnapshotNotFoundException; import com.project.imdang.insight.service.domain.handler.ExchangeRequestCreatedRequestMessagePublisher; import com.project.imdang.insight.service.domain.handler.ExchangeRequestHelper; @@ -25,9 +24,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; -import static com.project.imdang.domain.exception.ErrorCode.MEMBER_15ACCUSED; -import static com.project.imdang.domain.exception.ErrorCode.MEMBER_5ACCUSED; - @Slf4j @RequiredArgsConstructor @@ -76,6 +72,7 @@ public RequestExchangeInsightResponse requestExchange(RequestExchangeInsightComm // TODO - 쿠폰 확인 Assert.notNull(requestExchangeInsightCommand.getMemberCouponId(), "MemberCouponId must not be null!"); MemberCouponId memberCouponId = new MemberCouponId(requestExchangeInsightCommand.getMemberCouponId()); + ExchangeRequest requestExchangeWithCoupon = exchangeDomainService.requestExchangeWithCoupon(exchangeRequest, requestedSnapshot, memberCouponId); saved = exchangeRequestHelper.save(requestExchangeWithCoupon); // TODO - CHECK : publish 위치 @@ -83,7 +80,6 @@ public RequestExchangeInsightResponse requestExchange(RequestExchangeInsightComm new ExchangeRequestCreatedRequestMessage(saved.getId().getValue())); } - // TODO - CHECK : 쿠폰 업데이트 실패 시, rollback 메소드에서 데이터 삭제하면? return exchangeRequestDataMapper.exchangeRequestToRequestExchangeInsightResponse(saved); } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/DetailInsightCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/DetailInsightCommandHandler.java index fa5ced06..45a3aa41 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/DetailInsightCommandHandler.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/DetailInsightCommandHandler.java @@ -62,9 +62,9 @@ public DetailInsightResponse detailInsight(DetailInsightQuery detailInsightQuery // 교환 신청 여부 확인 Optional optional = exchangeRequestRepository.findByRequestMemberIdAndRequestedInsightId(requestedBy, insightId); - ExchangeRequestStatus exchangeRequestStatus = optional.map(ExchangeRequest::getStatus).orElse(null); + ExchangeRequest exchangeRequest = optional.orElse(null); // TODO - CHECK : OR snapshotRepository - return insightDataMapper.insightToDetailInsightResponse(insight, exchangeRequestStatus); + return insightDataMapper.insightToDetailInsightResponse(insight, exchangeRequest); } else { // 2. 교환 신청 여부 확인 @@ -78,10 +78,10 @@ public DetailInsightResponse detailInsight(DetailInsightQuery detailInsightQuery SnapshotId snapshotId = exchangeRequest.getRequestedSnapshotId(); Snapshot snapshot = snapshotRepository.findById(snapshotId) .orElseThrow(() -> new SnapshotNotFoundException(snapshotId)); - return snapshotDataMapper.snapshotToDetailInsightResponse(snapshot, exchangeRequest.getStatus()); + return snapshotDataMapper.snapshotToDetailInsightResponse(snapshot, exchangeRequest); } else { // PENDING, REJECTED - return insightDataMapper.insightToDetailInsightResponse(insight, exchangeRequest.getStatus()) + return insightDataMapper.insightToDetailInsightResponse(insight, exchangeRequest) .toPreviewInsightResponse(); } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListApartmentComplexByDistrictCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightApartmentComplexByDistrictCommandHandler.java similarity index 87% rename from insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListApartmentComplexByDistrictCommandHandler.java rename to insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightApartmentComplexByDistrictCommandHandler.java index 8f5a61b0..5c79a26b 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListApartmentComplexByDistrictCommandHandler.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightApartmentComplexByDistrictCommandHandler.java @@ -16,12 +16,12 @@ @Slf4j @RequiredArgsConstructor @Component -public class ListApartmentComplexByDistrictCommandHandler { +public class ListMyInsightApartmentComplexByDistrictCommandHandler { private final MemberSnapshotRepository memberSnapshotRepository; @Transactional(readOnly = true) - public List listApartmentComplexByDistrict(UUID _memberId, District district) { + public List listMyInsightApartmentComplexByDistrict(UUID _memberId, District district) { MemberId memberId = new MemberId(_memberId); List results = memberSnapshotRepository.findAllDistinctApartmentComplexAndInsightCountByMemberIdAndDistrict(memberId, district); return results.stream() diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCreatedByMeCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCreatedByMeCommandHandler.java new file mode 100644 index 00000000..88be79b5 --- /dev/null +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCreatedByMeCommandHandler.java @@ -0,0 +1,52 @@ +package com.project.imdang.insight.service.domain.handler.insight; + +import com.project.imdang.domain.utils.PagingUtils; +import com.project.imdang.domain.valueobject.MemberId; +import com.project.imdang.insight.service.domain.dto.insight.list.InsightSimpleResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightCreatedByMeQuery; +import com.project.imdang.insight.service.domain.entity.MemberSnapshot; +import com.project.imdang.insight.service.domain.mapper.SnapshotDataMapper; +import com.project.imdang.insight.service.domain.ports.output.repository.MemberSnapshotRepository; +import com.project.imdang.insight.service.domain.ports.output.repository.SnapshotRepository; +import com.project.imdang.insight.service.domain.valueobject.SnapshotId; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Slf4j +@RequiredArgsConstructor +@Component +public class ListMyInsightCreatedByMeCommandHandler { + + private final MemberSnapshotRepository memberSnapshotRepository; + private final SnapshotRepository snapshotRepository; + private final SnapshotDataMapper snapshotDataMapper; + + @Transactional(readOnly = true) + public Page listMyInsightCreatedByMe(ListMyInsightCreatedByMeQuery listMyInsightCreatedByMeQuery) { + + PageRequest pageRequest = PagingUtils.getPageRequest( + listMyInsightCreatedByMeQuery.getPageNumber(), listMyInsightCreatedByMeQuery.getPageSize(), listMyInsightCreatedByMeQuery.getDirection(), listMyInsightCreatedByMeQuery.getProperties()); + + MemberId memberId = new MemberId(listMyInsightCreatedByMeQuery.getMemberId()); + Page paged = memberSnapshotRepository.findAllByMemberIdAndSnapshotMemberId(memberId, memberId, pageRequest); + + List insightSimpleResponses = getInsightResponses(paged); + return new PageImpl<>(insightSimpleResponses, paged.getPageable(), paged.getTotalElements()); + } + + private List getInsightResponses(Page paged) { + List snapshotIds = paged.getContent().stream() + .map(MemberSnapshot::getSnapshotId) + .toList(); + return snapshotRepository.findAllByIds(snapshotIds).stream() + .map(snapshotDataMapper::snapshotToInsightSimpleResponse) + .toList(); + } +} diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/InsightDataMapper.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/InsightDataMapper.java index 6f626fbf..f8f0dfba 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/InsightDataMapper.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/InsightDataMapper.java @@ -9,8 +9,8 @@ import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; import com.project.imdang.insight.service.domain.dto.insight.recommend.RecommendInsightResponse; import com.project.imdang.insight.service.domain.dto.insight.update.UpdateInsightResponse; +import com.project.imdang.insight.service.domain.entity.ExchangeRequest; import com.project.imdang.insight.service.domain.entity.Insight; -import com.project.imdang.insight.service.domain.valueobject.ExchangeRequestStatus; import org.springframework.stereotype.Component; @Component @@ -76,7 +76,7 @@ public RecommendInsightResponse insightToRecommendInsightResponse(Insight insigh .build(); } - public DetailInsightResponse insightToDetailInsightResponse(Insight insight, ExchangeRequestStatus exchangeRequestStatus) { + public DetailInsightResponse insightToDetailInsightResponse(Insight insight, ExchangeRequest exchangeRequest) { return DetailInsightResponse.builder() .memberId(insight.getMemberId().getValue()) .insightId(insight.getId().getValue()) @@ -99,7 +99,8 @@ public DetailInsightResponse insightToDetailInsightResponse(Insight insight, Exc .score(insight.getScore()) .createdAt(insight.getCreatedAt()) // TODO - CHECK - .exchangeRequestStatus(exchangeRequestStatus) + .exchangeRequestStatus(exchangeRequest != null ? exchangeRequest.getStatus() : null) + .exchangeRequestId(exchangeRequest != null ? exchangeRequest.getId().getValue() : null) .build(); } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/SnapshotDataMapper.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/SnapshotDataMapper.java index 41e46a3c..abc513ba 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/SnapshotDataMapper.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/mapper/SnapshotDataMapper.java @@ -2,8 +2,9 @@ import com.project.imdang.insight.service.domain.dto.insight.detail.DetailInsightResponse; import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.InsightSimpleResponse; +import com.project.imdang.insight.service.domain.entity.ExchangeRequest; import com.project.imdang.insight.service.domain.entity.Snapshot; -import com.project.imdang.insight.service.domain.valueobject.ExchangeRequestStatus; import org.springframework.stereotype.Component; @Component @@ -12,6 +13,7 @@ public class SnapshotDataMapper { public InsightResponse snapshotToInsightResponse(Snapshot snapshot) { return InsightResponse.builder() .insightId(snapshot.getInsightId().getValue()) + .recommendedCount(null) .address(snapshot.getAddress()) .title(snapshot.getTitle()) .mainImage(snapshot.getMainImage()) @@ -19,11 +21,20 @@ public InsightResponse snapshotToInsightResponse(Snapshot snapshot) { .build(); } - public DetailInsightResponse snapshotToDetailInsightResponse(Snapshot snapshot, ExchangeRequestStatus exchangeRequestStatus) { + public InsightSimpleResponse snapshotToInsightSimpleResponse(Snapshot snapshot) { + return InsightSimpleResponse.builder() + .insightId(snapshot.getInsightId().getValue()) + .recommendedCount(null) + .address(snapshot.getAddress()) + .title(snapshot.getTitle()) + .build(); + } + + public DetailInsightResponse snapshotToDetailInsightResponse(Snapshot snapshot, ExchangeRequest exchangeRequest) { return DetailInsightResponse.builder() - .snapshotId(snapshot.getId().getValue()) .memberId(snapshot.getMemberId().getValue()) .insightId(snapshot.getInsightId().getValue()) + .snapshotId(snapshot.getId().getValue()) .mainImage(snapshot.getMainImage()) .title(snapshot.getTitle()) .address(snapshot.getAddress()) @@ -37,8 +48,12 @@ public DetailInsightResponse snapshotToDetailInsightResponse(Snapshot snapshot, .complexEnvironment(snapshot.getComplexEnvironment()) .complexFacility(snapshot.getComplexFacility()) .favorableNews(snapshot.getFavorableNews()) + .recommendedCount(null) + .accusedCount(null) + .viewCount(null) // TODO - CHECK - .exchangeRequestStatus(exchangeRequestStatus) + .exchangeRequestStatus(exchangeRequest != null ? exchangeRequest.getStatus() : null) + .exchangeRequestId(exchangeRequest != null ? exchangeRequest.getId().getValue() : null) .build(); } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/input/service/InsightApplicationService.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/input/service/InsightApplicationService.java index 19100ef7..8d5588d4 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/input/service/InsightApplicationService.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/input/service/InsightApplicationService.java @@ -8,12 +8,14 @@ import com.project.imdang.insight.service.domain.dto.insight.delete.DeleteInsightResponse; import com.project.imdang.insight.service.domain.dto.insight.detail.DetailInsightQuery; import com.project.imdang.insight.service.domain.dto.insight.detail.DetailInsightResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.ApartmentComplexResponse; import com.project.imdang.insight.service.domain.dto.insight.list.DistrictResponse; import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; +import com.project.imdang.insight.service.domain.dto.insight.list.InsightSimpleResponse; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightByApartmentComplexQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightQuery; +import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightCreatedByMeQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListMyInsightQuery; -import com.project.imdang.insight.service.domain.dto.insight.list.ApartmentComplexResponse; import com.project.imdang.insight.service.domain.dto.insight.recommend.RecommendInsightCommand; import com.project.imdang.insight.service.domain.dto.insight.recommend.RecommendInsightResponse; import com.project.imdang.insight.service.domain.dto.insight.update.UpdateInsightCommand; @@ -31,8 +33,9 @@ public interface InsightApplicationService { List listMyVisitedApartmentComplex(UUID memberId); List listMyInsightDistrict(UUID memberId); - List listApartmentComplexByDistrict(UUID memberId, District district); + List listMyInsightApartmentComplexByDistrict(UUID memberId, District district); Page listMyInsight(ListMyInsightQuery listMyInsightQuery); + Page listMyInsightCreatedByMe(ListMyInsightCreatedByMeQuery listMyInsightCreatedByMeQuery); DetailInsightResponse detailInsight(DetailInsightQuery detailInsightQuery); // = uploadInsight diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/output/repository/MemberSnapshotRepository.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/output/repository/MemberSnapshotRepository.java index c0b746ba..f7afa25b 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/output/repository/MemberSnapshotRepository.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/ports/output/repository/MemberSnapshotRepository.java @@ -17,6 +17,8 @@ public interface MemberSnapshotRepository { Optional findByMemberIdAndInsightId(MemberId memberId, InsightId insightId); Page findAllByMemberIdAndDistrict(MemberId memberId, District district, PageRequest pageRequest); Page findAllByMemberIdAndApartmentComplex(MemberId memberId, ApartmentComplex apartmentComplex, PageRequest pageRequest); + + Page findAllByMemberIdAndSnapshotMemberId(MemberId memberId, MemberId snapshotMemberId, PageRequest pageRequest); Page findAllByMemberIdAndDistrictAndSnapshotMemberId(MemberId memberId, District district, MemberId snapshotMemberId, PageRequest pageRequest); Page findAllByMemberIdAndApartmentComplexAndSnapshotMemberId(MemberId memberId, ApartmentComplex apartmentComplex, MemberId createdBy, PageRequest pageRequest); diff --git a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/adapter/MemberSnapshotRepositoryImpl.java b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/adapter/MemberSnapshotRepositoryImpl.java index 50e97342..549ae75c 100644 --- a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/adapter/MemberSnapshotRepositoryImpl.java +++ b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/adapter/MemberSnapshotRepositoryImpl.java @@ -45,6 +45,12 @@ public Page findAllByMemberIdAndApartmentComplex(MemberId member .map(memberSnapshotPersistenceMapper::memberSnapshotEntityToMemberSnapshot); } + @Override + public Page findAllByMemberIdAndSnapshotMemberId(MemberId memberId, MemberId snapshotMemberId, PageRequest pageRequest) { + return memberSnapshotJpaRepository.findAllByMemberIdAndSnapshotMemberId(memberId.getValue().toString(), snapshotMemberId.getValue().toString(), pageRequest) + .map(memberSnapshotPersistenceMapper::memberSnapshotEntityToMemberSnapshot); + } + @Override public Page findAllByMemberIdAndDistrictAndSnapshotMemberId(MemberId memberId, District district, MemberId snapshotMemberId, PageRequest pageRequest) { return memberSnapshotJpaRepository.findAllByMemberIdAndDistrictAndSnapshotMemberId( diff --git a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/repository/MemberSnapshotJpaRepository.java b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/repository/MemberSnapshotJpaRepository.java index 350a0b3b..8bc995b0 100644 --- a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/repository/MemberSnapshotJpaRepository.java +++ b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/repository/MemberSnapshotJpaRepository.java @@ -32,6 +32,13 @@ public interface MemberSnapshotJpaRepository extends JpaRepository findAllByMemberIdAndApartmentComplexName(String memberId, String apartmentComplexName, PageRequest pageRequest); + @Query(value = "select ms.* from member_snapshot ms inner join snapshot s on ms.snapshot_id = s.id " + + "where ms.member_id = :memberId and s.member_id = :snapshotMemberId \n-- #pageRequest\n", + countQuery = "select count(*) from member_snapshot ms inner join snapshot s on ms.snapshot_id = s.id " + + "where ms.member_id = :memberId and s.member_id = :snapshotMemberId", + nativeQuery = true) + Page findAllByMemberIdAndSnapshotMemberId(String memberId, String snapshotMemberId, Pageable pageable); + @Query(value = "select ms.* from member_snapshot ms inner join snapshot s on ms.snapshot_id = s.id " + "where ms.member_id = :memberId and s.address_si_do = :siDo and s.address_si_gun_gu = :siGunGu and s.address_eup_myeon_dong = :eupMyeonDong " + "and s.member_id = :snapshotMemberId \n-- #pageRequest\n",