diff --git a/be/src/main/java/com/podmate/domain/pod/application/PodService.java b/be/src/main/java/com/podmate/domain/pod/application/PodService.java index 40a72da..f717521 100644 --- a/be/src/main/java/com/podmate/domain/pod/application/PodService.java +++ b/be/src/main/java/com/podmate/domain/pod/application/PodService.java @@ -147,6 +147,18 @@ private PodResponse mapToPodResponseDto(Pod pod, Set jjimPodIds) { return null; // PodType이 두 가지 외에는 처리되지 않음 } + private PodResponse mapToPodResponseDtoForMap(Pod pod, Set jjimPodIds, boolean includeAddress) { + boolean isJJim = jjimPodIds.contains(pod.getId()); + + if (pod.getPodType() == PodType.MINIMUM) { + return buildMinimumPodResponseDtoForMap(pod, isJJim, true); + } else if (pod.getPodType() == PodType.GROUP_BUY) { + return buildGroupBuyPodResponseDtoForMap(pod, isJJim, true); + } + + return null; // PodType이 두 가지 외에는 처리되지 않음 + } + //사용자 주변 팟 거리 계산 메서드 private double calculateDistance(double lat1, double lon1, Pod pod) { double lat2 = pod.getAddress().getLatitude(); @@ -322,7 +334,7 @@ public List getPodsInBounds( Set jJimPodIds = getJJimPodIds(userId); return pods.stream() - .map(pod -> mapToPodResponseDto(pod, jJimPodIds)) + .map(pod -> mapToPodResponseDtoForMap(pod, jJimPodIds, true)) .collect(Collectors.toList()); } diff --git a/be/src/main/java/com/podmate/domain/pod/converter/PodConverter.java b/be/src/main/java/com/podmate/domain/pod/converter/PodConverter.java index c87425b..f360a60 100644 --- a/be/src/main/java/com/podmate/domain/pod/converter/PodConverter.java +++ b/be/src/main/java/com/podmate/domain/pod/converter/PodConverter.java @@ -1,5 +1,6 @@ package com.podmate.domain.pod.converter; +import com.podmate.domain.address.domain.entity.Address; import com.podmate.domain.orderForm.domain.entity.OrderForm; import com.podmate.domain.pod.domain.entity.Pod; import com.podmate.domain.pod.dto.PodResponseDto; @@ -13,7 +14,7 @@ public class PodConverter { public static PodResponseDto.Minimum buildMinimumPodResponseDto(Pod pod, boolean isJJim) { - return PodResponseDto.Minimum.builder() + return PodResponseDto.Minimum.builder() .podId(pod.getId()) .podName(pod.getPodName()) .podType(pod.getPodType().name()) @@ -24,6 +25,26 @@ public static PodResponseDto.Minimum buildMinimumPodResponseDto(Pod pod, boolean .build(); } + public static PodResponseDto.Minimum buildMinimumPodResponseDtoForMap(Pod pod, boolean isJJim, boolean includeAddress) { + Address address = pod.getAddress(); + return PodResponseDto.Minimum.builder() + .podId(pod.getId()) + .podName(pod.getPodName()) + .podType(pod.getPodType().name()) + .platform(pod.getPlatform().name()) + .goalAmount(pod.getGoalAmount()) + .currentAmount(pod.getCurrentAmount()) + .isJJim(isJJim) + + // ✅ 주소 필드 세팅 + .addressId(address.getId()) + .roadAddress(address.getRoadAddress()) + .latitude(address.getLatitude()) + .longitude(address.getLongitude()) + + .build(); + } + public static PodResponseDto.GroupBuy buildGroupBuyPodResponseDto(Pod pod, boolean isJJim) { return PodResponseDto.GroupBuy.builder() .podId(pod.getId()) @@ -36,6 +57,26 @@ public static PodResponseDto.GroupBuy buildGroupBuyPodResponseDto(Pod pod, boole .build(); } + public static PodResponseDto.GroupBuy buildGroupBuyPodResponseDtoForMap(Pod pod, boolean isJJim, boolean includeAddress) { + Address address = pod.getAddress(); + return PodResponseDto.GroupBuy.builder() + .podId(pod.getId()) + .podName(pod.getPodName()) + .podType(pod.getPodType().name()) + .itemUrl(pod.getItemUrl()) + .goalAmount(pod.getGoalAmount()) + .currentAmount(pod.getCurrentAmount()) + .isJJim(isJJim) + + // 주소 필드 세팅 + .addressId(address.getId()) + .roadAddress(address.getRoadAddress()) + .latitude(address.getLatitude()) + .longitude(address.getLongitude()) + + .build(); + } + public static PodResponseDto.MinimumDetail buildMinimumDetailResponseDto(Pod pod, boolean isJJim, PodResponseDto.PodLeader podLeaderDto) { return PodResponseDto.MinimumDetail.builder() .podId(pod.getId()) diff --git a/be/src/main/java/com/podmate/domain/pod/dto/PodResponseDto.java b/be/src/main/java/com/podmate/domain/pod/dto/PodResponseDto.java index d84e98c..04c021c 100644 --- a/be/src/main/java/com/podmate/domain/pod/dto/PodResponseDto.java +++ b/be/src/main/java/com/podmate/domain/pod/dto/PodResponseDto.java @@ -25,6 +25,12 @@ public static class Minimum implements PodResponse{ private int goalAmount; //목표 금액 or 목표 인원 private int currentAmount; //현재 금액 or 현재 인원 private boolean isJJim; + + // 주소 필드 추가 + private Long addressId; + private String roadAddress; + private double latitude; + private double longitude; } @Builder @@ -91,6 +97,13 @@ public static class GroupBuy implements PodResponse{ private int goalAmount; //목표 금액 or 목표 인원 private int currentAmount; //현재 금액 or 현재 인원 private boolean isJJim; + + // 주소 필드 추가 + private Long addressId; + private String roadAddress; + private double latitude; + private double longitude; + } @Builder @Getter