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 897e22f..05b3c94 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 @@ -1,10 +1,11 @@ package com.project.imdang.insight.service.application.rest; +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.ListMyInsightQuery; import com.project.imdang.insight.service.domain.dto.insight.list.MyInsightResponse; import com.project.imdang.insight.service.domain.ports.input.service.InsightApplicationService; -import com.project.imdang.insight.service.domain.valueobject.Address; +import com.project.imdang.insight.service.domain.valueobject.District; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -27,16 +28,17 @@ public class MyInsightController { // 보관함 private final InsightApplicationService insightApplicationService; - @GetMapping("/addresses") - public ResponseEntity> listAddress(@AuthenticationPrincipal UUID memberId) { - List
addresses = insightApplicationService.listMyInsightAddress(memberId); - return ResponseEntity.ok(addresses); + // 보관중인 인사이트 자치구 목록 API + @GetMapping("/districts") + public ResponseEntity> listDistrict(@AuthenticationPrincipal UUID memberId) { + List districtResponses = insightApplicationService.listMyInsightDistrict(memberId); + return ResponseEntity.ok(districtResponses); } - @GetMapping("/by-address") - public ResponseEntity countByAddress(@AuthenticationPrincipal UUID memberId, - @ModelAttribute Address address) { - MyInsightResponse myInsightResponse = insightApplicationService.countMyInsightByAddress(memberId, address); + @GetMapping("/by-district") + public ResponseEntity countByDistrict(@AuthenticationPrincipal UUID memberId, + @ModelAttribute District district) { + MyInsightResponse myInsightResponse = insightApplicationService.countMyInsightByDistrict(memberId, district); return ResponseEntity.ok(myInsightResponse); } @@ -45,18 +47,18 @@ public ResponseEntity countByAddress(@AuthenticationPrincipal // + 단지별 보기 @GetMapping public ResponseEntity> list(@AuthenticationPrincipal UUID memberId, - @RequestParam(name = "address") Address address, + @ModelAttribute District district, @RequestParam(name = "apartmentComplexName", required = false) String apartmentComplexName, @RequestParam(name = "onlyMine", defaultValue = "FALSE") Boolean onlyMine, // 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 = "createdAt") String[] properties) { + @RequestParam(name = "properties", defaultValue = "created_at") String[] properties) { ListMyInsightQuery listMyInsightQuery = ListMyInsightQuery.builder() .memberId(memberId) - .address(address) + .district(district) .apartmentComplexName(apartmentComplexName) .onlyMine(onlyMine) .pageNumber(pageNumber) diff --git a/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/ExchangeControllerTest.java b/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/ExchangeControllerTest.java index e2d97c9..acdfc31 100644 --- a/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/ExchangeControllerTest.java +++ b/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/ExchangeControllerTest.java @@ -6,6 +6,7 @@ import com.project.imdang.insight.service.domain.dto.exchange.reject.RejectExchangeRequestCommand; import com.project.imdang.insight.service.domain.dto.exchange.request.RequestExchangeInsightCommand; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -68,9 +69,9 @@ public void request() throws Exception { .andExpect(jsonPath("$.exchangeRequestId", notNullValue())); } -// @Test + @Test public void request_with_coupon() throws Exception { - UUID insightId = UUID.fromString("111512ab-a7b6-43f9-bd61-16ee2cded7d9"); + UUID insightId = UUID.fromString("f509ce55-a67a-4c97-8846-0dee0c754c38"); RequestExchangeInsightCommand requestExchangeInsightCommand = new TestData(insightId).requestExchangeInsightCommand(null, 1L) ; @@ -82,10 +83,10 @@ public void request_with_coupon() throws Exception { .andExpect(jsonPath("$.exchangeRequestId", notNullValue())); } -// @Test + @Test public void accept() throws Exception { AcceptExchangeRequestCommand acceptExchangeRequestCommand = AcceptExchangeRequestCommand.builder() - .exchangeRequestId(UUID.fromString("a4c9a9e8-2577-4a4d-9bf1-3f76687336dd")) + .exchangeRequestId(UUID.fromString("61ec70ab-2baf-47b1-80a6-c5d551bfccc9")) .requestedMemberId(requestedMemberId) .build(); mockMvc.perform(post("/exchanges/accept") diff --git a/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/InsightControllerTest.java b/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/InsightControllerTest.java index f00783d..2d28cd5 100644 --- a/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/InsightControllerTest.java +++ b/insight-service/insight-container/src/test/java/com/project/imdang/insight/service/application/rest/InsightControllerTest.java @@ -144,7 +144,7 @@ void updateInsight() throws Exception { @Test void recommendInsight() throws Exception { - UUID insightId = UUID.fromString("b434b945-5e39-4439-b0eb-ff953b777118"); + UUID insightId = UUID.fromString("f509ce55-a67a-4c97-8846-0dee0c754c38"); RecommendInsightCommand recommendInsightCommand = new TestData(insightId).recommendInsightCommand(); mockMvc.perform(post("/insights/recommend") .header("Authorization", "Bearer " + requestMemberToken) 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 2144293..c18e7ea 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 @@ -49,8 +49,8 @@ void init() { } @Test - void listAddress() throws Exception { - mockMvc.perform(get("/my-insights/addresses") + void listDistrict() throws Exception { + mockMvc.perform(get("/my-insights/districts") .header("Authorization", "Bearer " + requestMemberToken) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) @@ -59,8 +59,8 @@ void listAddress() throws Exception { } @Test - void countByAddress() throws Exception { - mockMvc.perform(get("/my-insights/by-address") + void countByDistrict() throws Exception { + mockMvc.perform(get("/my-insights/by-district") .header("Authorization", "Bearer " + requestMemberToken) .param("siDo", "서울시") .param("siGunGu", "강남구") @@ -75,7 +75,10 @@ void countByAddress() throws Exception { void list() throws Exception { mockMvc.perform(get("/my-insights") .header("Authorization", "Bearer " + requestMemberToken) - .param("onlyMine", "TRUE") +// .param("onlyMine", "TRUE") + .param("siDo", "서울시") + .param("siGunGu", "강남구") + .param("eupMyeonDong", "신논현동") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) // .andExpect(jsonPath("$.content.length()").value(1)) 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 5a7add1..35e35b5 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 @@ -8,6 +8,7 @@ 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.DistrictResponse; import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightByApartmentComplexQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightQuery; @@ -18,20 +19,20 @@ import com.project.imdang.insight.service.domain.dto.insight.update.UpdateInsightCommand; import com.project.imdang.insight.service.domain.dto.insight.update.UpdateInsightResponse; import com.project.imdang.insight.service.domain.handler.insight.AccuseInsightCommandHandler; -import com.project.imdang.insight.service.domain.handler.insight.CountMyInsightByAddressCommandHandler; +import com.project.imdang.insight.service.domain.handler.insight.CountMyInsightByDistrictCommandHandler; 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.ListInsightByApartmentComplexCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListInsightCommandHandler; -import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightAddressCommandHandler; +import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightDistrictCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListMyInsightCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.ListMyVisitedApartmentComplexCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.RecommendInsightCommandHandler; import com.project.imdang.insight.service.domain.handler.insight.UpdateInsightCommandHandler; import com.project.imdang.insight.service.domain.ports.input.service.InsightApplicationService; -import com.project.imdang.insight.service.domain.valueobject.Address; import com.project.imdang.insight.service.domain.valueobject.ApartmentComplex; +import com.project.imdang.insight.service.domain.valueobject.District; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @@ -50,8 +51,8 @@ public class InsightApplicationServiceImpl implements InsightApplicationService private final ListMyVisitedApartmentComplexCommandHandler listMyVisitedApartmentComplexCommandHandler; - private final ListMyInsightAddressCommandHandler listMyInsightAddressCommandHandler; - private final CountMyInsightByAddressCommandHandler countMyInsightByAddressCommandHandler; + private final ListMyInsightDistrictCommandHandler listMyInsightDistrictCommandHandler; + private final CountMyInsightByDistrictCommandHandler countMyInsightByDistrictCommandHandler; private final ListMyInsightCommandHandler listMyInsightCommandHandler; private final DetailInsightCommandHandler detailInsightCommandHandler; @@ -78,13 +79,13 @@ public List listMyVisitedApartmentComplex(UUID memberId) { } @Override - public List
listMyInsightAddress(UUID memberId) { - return listMyInsightAddressCommandHandler.listMyInsightAddress(memberId); + public List listMyInsightDistrict(UUID memberId) { + return listMyInsightDistrictCommandHandler.listMyInsightDistrict(memberId); } @Override - public MyInsightResponse countMyInsightByAddress(UUID memberId, Address address) { - return countMyInsightByAddressCommandHandler.countMyInsightByAddress(memberId, address); + public MyInsightResponse countMyInsightByDistrict(UUID memberId, District district) { + return countMyInsightByDistrictCommandHandler.countMyInsightByDistrict(memberId, district); } @Override diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/DistrictResponse.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/DistrictResponse.java new file mode 100644 index 0000000..6f267c3 --- /dev/null +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/DistrictResponse.java @@ -0,0 +1,20 @@ +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; + +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class DistrictResponse { + private String siDo; // 시/도 (예: 서울특별시) + private String siGunGu; // 시/군/구 (예: 종로구) + private String eupMyeonDong; // 읍/면/동 (예: 효제동) + + private Long apartmentComplexCount; + private Long insightCount; +} diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightQuery.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightQuery.java index 5e4e5c5..4bc77f9 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightQuery.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/ListMyInsightQuery.java @@ -1,6 +1,6 @@ package com.project.imdang.insight.service.domain.dto.insight.list; -import com.project.imdang.insight.service.domain.valueobject.Address; +import com.project.imdang.insight.service.domain.valueobject.District; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -17,7 +17,7 @@ public class ListMyInsightQuery { // extends PagingQuery { // @Setter private UUID memberId; - private Address address; + private District district; private String apartmentComplexName; private Boolean onlyMine; diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/MyInsightResponse.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/MyInsightResponse.java index b6ef6fd..4b4a1cf 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/MyInsightResponse.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/dto/insight/list/MyInsightResponse.java @@ -16,5 +16,5 @@ public class MyInsightResponse { // private int apartmentComplexCount; private List apartmentComplexes; - private int insightCount; + private Long insightCount; } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/CountMyInsightByAddressCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/CountMyInsightByDistrictCommandHandler.java similarity index 68% rename from insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/CountMyInsightByAddressCommandHandler.java rename to insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/CountMyInsightByDistrictCommandHandler.java index db7ce4d..3e2cae6 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/CountMyInsightByAddressCommandHandler.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/CountMyInsightByDistrictCommandHandler.java @@ -3,8 +3,8 @@ import com.project.imdang.domain.valueobject.MemberId; import com.project.imdang.insight.service.domain.dto.insight.list.MyInsightResponse; import com.project.imdang.insight.service.domain.ports.output.repository.MemberSnapshotRepository; -import com.project.imdang.insight.service.domain.valueobject.Address; import com.project.imdang.insight.service.domain.valueobject.ApartmentComplex; +import com.project.imdang.insight.service.domain.valueobject.District; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -16,15 +16,17 @@ @Slf4j @RequiredArgsConstructor @Component -public class CountMyInsightByAddressCommandHandler { +public class CountMyInsightByDistrictCommandHandler { private final MemberSnapshotRepository memberSnapshotRepository; @Transactional(readOnly = true) - public MyInsightResponse countMyInsightByAddress(UUID _memberId, Address address) { + public MyInsightResponse countMyInsightByDistrict(UUID _memberId, District district) { MemberId memberId = new MemberId(_memberId); - List apartmentComplexes = memberSnapshotRepository.findAllDistinctApartmentComplexByMemberIdAndAddress(memberId, address); - int insightCount = memberSnapshotRepository.countAllByMemberIdAndAddress(memberId, address); + List apartmentComplexes = memberSnapshotRepository.findAllDistinctApartmentComplexByMemberIdAndDistrict(memberId, district); + Long[] counts = memberSnapshotRepository.countAllByMemberIdAndDistrict(memberId, district); +// Long apartmentComplexCount = counts[0]; + Long insightCount = counts[1]; return MyInsightResponse.builder() .apartmentComplexes(apartmentComplexes) .insightCount(insightCount) diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightAddressCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightAddressCommandHandler.java deleted file mode 100644 index dd5a3f7..0000000 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightAddressCommandHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.project.imdang.insight.service.domain.handler.insight; - -import com.project.imdang.domain.valueobject.MemberId; -import com.project.imdang.insight.service.domain.ports.output.repository.MemberSnapshotRepository; -import com.project.imdang.insight.service.domain.valueobject.Address; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.UUID; - -@Slf4j -@RequiredArgsConstructor -@Component -public class ListMyInsightAddressCommandHandler { - - private final MemberSnapshotRepository memberSnapshotRepository; - - @Transactional(readOnly = true) - public List
listMyInsightAddress(UUID _memberId) { - MemberId memberId = new MemberId(_memberId); - return memberSnapshotRepository.findAllDistinctAddressByMemberId(memberId); - } -} diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCommandHandler.java index a1ec437..19ee918 100644 --- a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCommandHandler.java +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightCommandHandler.java @@ -52,9 +52,9 @@ public Page listMyInsight(ListMyInsightQuery listMyInsightQuery } else { if (Boolean.TRUE.equals(onlyMine)) { - paged = memberSnapshotRepository.findAllByMemberIdAndAddressAndSnapshotMemberId(memberId, listMyInsightQuery.getAddress(), memberId, pageRequest); + paged = memberSnapshotRepository.findAllByMemberIdAndDistrictAndSnapshotMemberId(memberId, listMyInsightQuery.getDistrict(), memberId, pageRequest); } else { - paged = memberSnapshotRepository.findAllByMemberIdAndAddress(memberId, listMyInsightQuery.getAddress(), pageRequest); + paged = memberSnapshotRepository.findAllByMemberIdAndDistrict(memberId, listMyInsightQuery.getDistrict(), pageRequest); } } diff --git a/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightDistrictCommandHandler.java b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightDistrictCommandHandler.java new file mode 100644 index 0000000..b9b5de7 --- /dev/null +++ b/insight-service/insight-domain/insight-application-service/src/main/java/com/project/imdang/insight/service/domain/handler/insight/ListMyInsightDistrictCommandHandler.java @@ -0,0 +1,49 @@ +package com.project.imdang.insight.service.domain.handler.insight; + +import com.project.imdang.domain.valueobject.MemberId; +import com.project.imdang.insight.service.domain.dto.insight.list.DistrictResponse; +import com.project.imdang.insight.service.domain.ports.output.repository.MemberSnapshotRepository; +import com.project.imdang.insight.service.domain.valueobject.District; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@Slf4j +@RequiredArgsConstructor +@Component +public class ListMyInsightDistrictCommandHandler { + + private final MemberSnapshotRepository memberSnapshotRepository; + + @Transactional(readOnly = true) + public List listMyInsightDistrict(UUID _memberId) { + MemberId memberId = new MemberId(_memberId); + List districts = memberSnapshotRepository.findAllDistinctDistrictByMemberId(memberId); + + // TODO - 쿼리 개선 + return districts.stream() + .map(_district -> { + String siDo = (String) _district[0]; + String siGunGu = (String) _district[1]; + String eupMyeonDong = (String) _district[2]; + District district = new District(siDo, siGunGu, eupMyeonDong); + Long[] result = memberSnapshotRepository.countAllByMemberIdAndDistrict(memberId, district); + + Long apartmentComplexCount = result[0]; + Long insightCount = result[1]; + return DistrictResponse.builder() + .siDo(siDo) + .siGunGu(siGunGu) + .eupMyeonDong(eupMyeonDong) + .apartmentComplexCount(apartmentComplexCount) + .insightCount(insightCount) + .build(); + }) + .collect(Collectors.toList()); + } +} 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 488b25c..e05697f 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,6 +8,7 @@ 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.DistrictResponse; import com.project.imdang.insight.service.domain.dto.insight.list.InsightResponse; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightByApartmentComplexQuery; import com.project.imdang.insight.service.domain.dto.insight.list.ListInsightQuery; @@ -17,8 +18,8 @@ import com.project.imdang.insight.service.domain.dto.insight.recommend.RecommendInsightResponse; import com.project.imdang.insight.service.domain.dto.insight.update.UpdateInsightCommand; import com.project.imdang.insight.service.domain.dto.insight.update.UpdateInsightResponse; -import com.project.imdang.insight.service.domain.valueobject.Address; import com.project.imdang.insight.service.domain.valueobject.ApartmentComplex; +import com.project.imdang.insight.service.domain.valueobject.District; import org.springframework.data.domain.Page; import java.util.List; @@ -29,8 +30,8 @@ public interface InsightApplicationService { Page listInsightByApartmentComplex(ListInsightByApartmentComplexQuery listInsightByApartmentComplexQuery); List listMyVisitedApartmentComplex(UUID memberId); - List
listMyInsightAddress(UUID memberId); - MyInsightResponse countMyInsightByAddress(UUID memberId, Address address); + List listMyInsightDistrict(UUID memberId); + MyInsightResponse countMyInsightByDistrict(UUID memberId, District district); Page listMyInsight(ListMyInsightQuery listMyInsightQuery); DetailInsightResponse detailInsight(DetailInsightQuery detailInsightQuery); 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 fef9240..3150962 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 @@ -1,11 +1,10 @@ package com.project.imdang.insight.service.domain.ports.output.repository; import com.project.imdang.domain.valueobject.InsightId; -import com.project.imdang.domain.valueobject.MemberCouponId; import com.project.imdang.domain.valueobject.MemberId; import com.project.imdang.insight.service.domain.entity.MemberSnapshot; -import com.project.imdang.insight.service.domain.valueobject.Address; import com.project.imdang.insight.service.domain.valueobject.ApartmentComplex; +import com.project.imdang.insight.service.domain.valueobject.District; import com.project.imdang.insight.service.domain.valueobject.SnapshotId; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -16,14 +15,15 @@ public interface MemberSnapshotRepository { Optional findByMemberIdAndInsightId(MemberId memberId, InsightId insightId); - Page findAllByMemberIdAndAddress(MemberId memberId, Address address, PageRequest pageRequest); + Page findAllByMemberIdAndDistrict(MemberId memberId, District district, PageRequest pageRequest); Page findAllByMemberIdAndApartmentComplex(MemberId memberId, ApartmentComplex apartmentComplex, PageRequest pageRequest); - Page findAllByMemberIdAndAddressAndSnapshotMemberId(MemberId memberId, Address address, MemberId snapshotMemberId, PageRequest pageRequest); + Page findAllByMemberIdAndDistrictAndSnapshotMemberId(MemberId memberId, District district, MemberId snapshotMemberId, PageRequest pageRequest); Page findAllByMemberIdAndApartmentComplexAndSnapshotMemberId(MemberId memberId, ApartmentComplex apartmentComplex, MemberId createdBy, PageRequest pageRequest); - List
findAllDistinctAddressByMemberId(MemberId memberId); - List findAllDistinctApartmentComplexByMemberIdAndAddress(MemberId memberId, Address address); - int countAllByMemberIdAndAddress(MemberId memberId, Address address); + List findAllDistinctDistrictByMemberId(MemberId memberId); + List findAllDistinctApartmentComplexByMemberIdAndDistrict(MemberId memberId, District district); +// int countAllByMemberIdAndAddress(MemberId memberId, Address address); + Long[] countAllByMemberIdAndDistrict(MemberId memberId, District district); MemberSnapshot save(MemberSnapshot memberSnapshot); void updateSnapshotIdByMemberIdAndInsightId(SnapshotId snapshotId, MemberId memberId, InsightId insightId); diff --git a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainService.java b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainService.java index 916a080..734ae97 100644 --- a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainService.java +++ b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainService.java @@ -43,6 +43,8 @@ InsightUpdatedEvent updateInsight(Insight insight, InsightAccusedEvent accuseInsight(Insight insight, MemberId accusedBy); // InsightRequestedEvent requestInsight(Insight insight); + void viewInsight(Insight insight); + // TODO - CHECK Snapshot captureInsight(Insight insight); } diff --git a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainServiceImpl.java b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainServiceImpl.java index 83e646f..4680479 100644 --- a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainServiceImpl.java +++ b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/InsightDomainServiceImpl.java @@ -86,6 +86,12 @@ public InsightAccusedEvent accuseInsight(Insight insight, MemberId accusedBy) { return new InsightAccusedEvent(insight, accuse, accuse.getCreatedAt()); } + @Override + public void viewInsight(Insight insight) { + insight.view(); + log.info("Insight[id: {}] is viewed.", insight.getId().getValue()); + } + @Override public Snapshot captureInsight(Insight insight) { Snapshot snapshot = insight.capture(); diff --git a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/Address.java b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/Address.java index 0eb3213..a3d055e 100644 --- a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/Address.java +++ b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/Address.java @@ -25,27 +25,26 @@ public class Address { @NotBlank private String eupMyeonDong; // 읍/면/동 (예: 효제동) @Schema(description = "도로명") - @NotBlank +// @NotBlank private String roadName; // 도로명 @Schema(description = "번지", example = "191") - @NotBlank +// @NotBlank private String buildingNumber; // 번지 (예: 191) private String detail; + private Double latitude; + private Double longitude; + @Override public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; Address address = (Address) o; - return Objects.equals(siDo, address.siDo) && Objects.equals(siGunGu, address.siGunGu) - && Objects.equals(eupMyeonDong, address.eupMyeonDong) && Objects.equals(roadName, address.roadName) - && Objects.equals(buildingNumber, address.buildingNumber) && Objects.equals(detail, address.detail); + return Objects.equals(siDo, address.siDo) && Objects.equals(siGunGu, address.siGunGu) && Objects.equals(eupMyeonDong, address.eupMyeonDong) && Objects.equals(roadName, address.roadName) && Objects.equals(buildingNumber, address.buildingNumber) && Objects.equals(detail, address.detail) && Objects.equals(latitude, address.latitude) && Objects.equals(longitude, address.longitude); } @Override public int hashCode() { - return Objects.hash(siDo, siGunGu, eupMyeonDong, roadName, buildingNumber, detail); + return Objects.hash(siDo, siGunGu, eupMyeonDong, roadName, buildingNumber, detail, latitude, longitude); } } diff --git a/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/District.java b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/District.java new file mode 100644 index 0000000..5672fc1 --- /dev/null +++ b/insight-service/insight-domain/insight-domain-core/src/main/java/com/project/imdang/insight/service/domain/valueobject/District.java @@ -0,0 +1,41 @@ +package com.project.imdang.insight.service.domain.valueobject; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.Objects; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class District { + + @Schema(description = "시/도", example = "서울특별시") + @NotBlank + private String siDo; // 시/도 (예: 서울특별시) + @Schema(description = "시/군/구", example = "종로구") + @NotBlank + private String siGunGu; // 시/군/구 (예: 종로구) + @Schema(description = "읍/면/동", example = "효제동") + @NotBlank + private String eupMyeonDong; // 읍/면/동 (예: 효제동) + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + District district = (District) o; + return Objects.equals(siDo, district.siDo) && Objects.equals(siGunGu, district.siGunGu) && Objects.equals(eupMyeonDong, district.eupMyeonDong); + } + + @Override + public int hashCode() { + return Objects.hash(siDo, siGunGu, eupMyeonDong); + } +} 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 3dff79d..4c3d506 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 @@ -4,12 +4,13 @@ import com.project.imdang.domain.valueobject.MemberId; import com.project.imdang.insight.service.domain.entity.MemberSnapshot; import com.project.imdang.insight.service.domain.ports.output.repository.MemberSnapshotRepository; -import com.project.imdang.insight.service.domain.valueobject.Address; import com.project.imdang.insight.service.domain.valueobject.ApartmentComplex; +import com.project.imdang.insight.service.domain.valueobject.District; import com.project.imdang.insight.service.domain.valueobject.SnapshotId; import com.project.imdang.insight.service.persistence.insight.entity.MemberSnapshotEntity; import com.project.imdang.insight.service.persistence.insight.mapper.MemberSnapshotPersistenceMapper; import com.project.imdang.insight.service.persistence.insight.repository.MemberSnapshotJpaRepository; +import jakarta.persistence.Tuple; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -33,9 +34,9 @@ public Optional findByMemberIdAndInsightId(MemberId memberId, In } @Override - public Page findAllByMemberIdAndAddress(MemberId memberId, Address address, PageRequest pageRequest) { - return memberSnapshotJpaRepository.findAllByMemberIdAndAddress( - memberId.getValue().toString(), address.getSiDo(), address.getSiGunGu(), address.getEupMyeonDong(), address.getRoadName(), address.getBuildingNumber(), address.getDetail(), pageRequest) + public Page findAllByMemberIdAndDistrict(MemberId memberId, District district, PageRequest pageRequest) { + return memberSnapshotJpaRepository.findAllByMemberIdAndDistrict( + memberId.getValue().toString(), district.getSiDo(), district.getSiGunGu(), district.getEupMyeonDong(), pageRequest) .map(memberSnapshotPersistenceMapper::memberSnapshotEntityToMemberSnapshot); } @@ -46,9 +47,9 @@ public Page findAllByMemberIdAndApartmentComplex(MemberId member } @Override - public Page findAllByMemberIdAndAddressAndSnapshotMemberId(MemberId memberId, Address address, MemberId snapshotMemberId, PageRequest pageRequest) { - return memberSnapshotJpaRepository.findAllByMemberIdAndAddressAndSnapshotMemberId( - memberId.getValue().toString(), address.getSiDo(), address.getSiGunGu(), address.getEupMyeonDong(), address.getRoadName(), address.getBuildingNumber(), address.getDetail(), snapshotMemberId.getValue(), pageRequest) + public Page findAllByMemberIdAndDistrictAndSnapshotMemberId(MemberId memberId, District district, MemberId snapshotMemberId, PageRequest pageRequest) { + return memberSnapshotJpaRepository.findAllByMemberIdAndDistrictAndSnapshotMemberId( + memberId.getValue().toString(), district.getSiDo(), district.getSiGunGu(), district.getEupMyeonDong(), snapshotMemberId.getValue(), pageRequest) .map(memberSnapshotPersistenceMapper::memberSnapshotEntityToMemberSnapshot); } @@ -59,32 +60,23 @@ public Page findAllByMemberIdAndApartmentComplexAndSnapshotMembe } @Override - public List
findAllDistinctAddressByMemberId(MemberId memberId) { - List results = memberSnapshotJpaRepository.findAllDistinctAddressByMemberId(memberId.getValue().toString()); - return results.stream() - .map(result -> new Address( - (String) result[0], - (String) result[1], - (String) result[2], - null, null, null -// (String) result[3], -// (String) result[4], -// (String) result[5] - ) - ) - .collect(Collectors.toList()); + public List findAllDistinctDistrictByMemberId(MemberId memberId) { + return memberSnapshotJpaRepository.findAllDistinctDistrictByMemberId(memberId.getValue().toString()); } @Override - public List findAllDistinctApartmentComplexByMemberIdAndAddress(MemberId memberId, Address address) { - return memberSnapshotJpaRepository.findAllDistinctApartmentComplexByMemberIdAndAddress(memberId.getValue().toString(), address.getSiDo(), address.getSiGunGu(), address.getEupMyeonDong(), address.getRoadName(), address.getBuildingNumber(), address.getDetail()).stream() + public List findAllDistinctApartmentComplexByMemberIdAndDistrict(MemberId memberId, District district) { + return memberSnapshotJpaRepository.findAllDistinctApartmentComplexByMemberIdAndDistrict(memberId.getValue().toString(), district.getSiDo(), district.getSiGunGu(), district.getEupMyeonDong()).stream() .map(ApartmentComplex::new) .collect(Collectors.toList()); } @Override - public int countAllByMemberIdAndAddress(MemberId memberId, Address address) { - return memberSnapshotJpaRepository.countAllByMemberIdAndAddress(memberId.getValue().toString(), address.getSiDo(), address.getSiGunGu(), address.getEupMyeonDong(), address.getRoadName(), address.getBuildingNumber(), address.getDetail()); + public Long[] countAllByMemberIdAndDistrict(MemberId memberId, District district) { + Tuple tuple = memberSnapshotJpaRepository.countAllByMemberIdAndDistrict(memberId.getValue().toString(), district.getSiDo(), district.getSiGunGu(), district.getEupMyeonDong()); + Long apartmentComplexCount = tuple.get("apartment_complex_count", Long.class); + Long insightCount = tuple.get("insight_count", Long.class); + return new Long[]{apartmentComplexCount, insightCount}; } @Override diff --git a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/InsightEntity.java b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/InsightEntity.java index 30931c0..8567cf7 100644 --- a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/InsightEntity.java +++ b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/InsightEntity.java @@ -68,6 +68,8 @@ public class InsightEntity { @AttributeOverride(name = "roadName", column = @Column(name = "address_road_name")), @AttributeOverride(name = "buildingNumber", column = @Column(name = "address_building_number")), @AttributeOverride(name = "detail", column = @Column(name = "address_detail")), + @AttributeOverride(name = "latitude", column = @Column(name = "address_latitude")), + @AttributeOverride(name = "longitude", column = @Column(name = "address_longitude")) }) private Address address; diff --git a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/SnapshotEntity.java b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/SnapshotEntity.java index f3886e4..a9641d1 100644 --- a/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/SnapshotEntity.java +++ b/insight-service/insight-persistence/src/main/java/com/project/imdang/insight/service/persistence/insight/entity/SnapshotEntity.java @@ -71,6 +71,8 @@ public class SnapshotEntity { @AttributeOverride(name = "roadName", column = @Column(name = "address_road_name")), @AttributeOverride(name = "buildingNumber", column = @Column(name = "address_building_number")), @AttributeOverride(name = "detail", column = @Column(name = "address_detail")), + @AttributeOverride(name = "latitude", column = @Column(name = "address_latitude")), + @AttributeOverride(name = "longitude", column = @Column(name = "address_longitude")) }) private Address address; 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 d2b8ccf..ff00800 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 @@ -1,7 +1,7 @@ package com.project.imdang.insight.service.persistence.insight.repository; -import com.project.imdang.insight.service.domain.valueobject.Address; import com.project.imdang.insight.service.persistence.insight.entity.MemberSnapshotEntity; +import jakarta.persistence.Tuple; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -19,18 +19,11 @@ public interface MemberSnapshotJpaRepository extends JpaRepository findByMemberIdAndInsightId(UUID memberId, UUID insightId); @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 (:roadName IS NULL OR s.address_road_name = :roadName) " + - "and (:buildingNumber IS NULL OR s.address_building_number = :buildingNumber) " + - "and (:detail IS NULL OR s.address_detail = :detail) " + - "\n-- #pageRequest\n", + "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 \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.address_si_do = :siDo and s.address_si_gun_gu = :siGunGu and s.address_eup_myeon_dong = :eupMyeonDong " + - "and (:roadName IS NULL OR s.address_road_name = :roadName) " + - "and (:buildingNumber IS NULL OR s.address_building_number = :buildingNumber) " + - "and (:detail IS NULL OR s.address_detail = :detail)", + "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", nativeQuery = true) - Page findAllByMemberIdAndAddress(String memberId, String siDo, String siGunGu, String eupMyeonDong, String roadName, String buildingNumber, String detail, Pageable pageable); + Page findAllByMemberIdAndDistrict(String memberId, String siDo, String siGunGu, String eupMyeonDong, 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.complex_name = :apartmentComplexName \n-- #pageRequest\n", @@ -41,18 +34,12 @@ public interface MemberSnapshotJpaRepository extends JpaRepository findAllByMemberIdAndAddressAndSnapshotMemberId(String memberId, String siDo, String siGunGu, String eupMyeonDong, String roadName, String buildingNumber, String detail, UUID snapshotMemberId, Pageable pageable); + Page findAllByMemberIdAndDistrictAndSnapshotMemberId(String memberId, String siDo, String siGunGu, String eupMyeonDong, UUID 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.complex_name = :apartmentComplexName and s.member_id = :snapshotMemberId \n-- #pageRequest\n", @@ -62,26 +49,24 @@ public interface MemberSnapshotJpaRepository extends JpaRepository findAllByMemberIdAndApartmentComplexNameAndSnapshotMemberId(String memberId, String apartmentComplexName, UUID snapshotMemberId, PageRequest pageRequest); @Query(value = "select distinct s.address_si_do, s.address_si_gun_gu, s.address_eup_myeon_dong " + -// ", s.address_road_name, s.address_building_number, s.address_detail " + "from member_snapshot ms inner join snapshot s on ms.snapshot_id = s.id where ms.member_id = :memberId", nativeQuery = true) - List findAllDistinctAddressByMemberId(String memberId); + List findAllDistinctDistrictByMemberId(String memberId); @Query(value = "select distinct s.complex_name 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 (:roadName IS NULL OR s.address_road_name = :roadName) " + - "and (:buildingNumber IS NULL OR s.address_building_number = :buildingNumber) " + - "and (:detail IS NULL OR s.address_detail = :detail)", + "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", nativeQuery = true) - List findAllDistinctApartmentComplexByMemberIdAndAddress(String memberId, String siDo, String siGunGu, String eupMyeonDong, String roadName, String buildingNumber, String detail); + List findAllDistinctApartmentComplexByMemberIdAndDistrict(String memberId, String siDo, String siGunGu, String eupMyeonDong); - @Query(value = "select count(*) 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 (:roadName IS NULL OR s.address_road_name = :roadName) " + - "and (:buildingNumber IS NULL OR s.address_building_number = :buildingNumber) " + - "and (:detail IS NULL OR s.address_detail = :detail) ", +// @Query(value = "select count(distinct s.complex_name) 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 ", +// nativeQuery = true) +// int countAllDistinctApartmentComplexByMemberIdAndDistinct(String memberId, String siDo, String siGunGu, String eupMyeonDong); + @Query(value = "select count(distinct s.complex_name) as apartment_complex_count, count(*) as insight_count 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 ", nativeQuery = true) - int countAllByMemberIdAndAddress(String memberId, String siDo, String siGunGu, String eupMyeonDong, String roadName, String buildingNumber, String detail); + Tuple countAllByMemberIdAndDistrict(String memberId, String siDo, String siGunGu, String eupMyeonDong); void deleteByMemberIdAndInsightId(UUID memberId, UUID insightId); }