-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from imdangg/feat/fix
위/경도 추가, District로 변환
- Loading branch information
Showing
22 changed files
with
225 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ain/java/com/project/imdang/insight/service/domain/dto/insight/list/DistrictResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
...ect/imdang/insight/service/domain/handler/insight/ListMyInsightAddressCommandHandler.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ct/imdang/insight/service/domain/handler/insight/ListMyInsightDistrictCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DistrictResponse> listMyInsightDistrict(UUID _memberId) { | ||
MemberId memberId = new MemberId(_memberId); | ||
List<Object[]> 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()); | ||
} | ||
} |
Oops, something went wrong.