Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public interface PinLocationRepository extends JpaRepository<PinLocation, Long>
ST_Y(pl.pin_point) AS lat,
ST_X(pl.pin_point) AS lng,
pl.detail_address AS detailAddress,
l.location AS region
l.location AS region,
CASE WHEN p.pin_type = 'STORE' THEN ep.discount ELSE NULL END AS discount
FROM pin_location pl
INNER JOIN pin p ON pl.pin_id = p.pin_id
INNER JOIN location l ON pl.location_id = l.location_id
Expand Down Expand Up @@ -79,7 +80,8 @@ List<MapPinView> findPinsInBoundingBox(
pl.detail_address AS detailAddress,
l.location AS region,
ST_Y(ST_SnapToGrid(pl.pin_point, :gridSize)) AS clusterLat,
ST_X(ST_SnapToGrid(pl.pin_point, :gridSize)) AS clusterLng
ST_X(ST_SnapToGrid(pl.pin_point, :gridSize)) AS clusterLng,
CASE WHEN p.pin_type = 'STORE' THEN ep.discount ELSE NULL END AS discount
FROM pin_location pl
INNER JOIN pin p ON pl.pin_id = p.pin_id
INNER JOIN location l ON pl.location_id = l.location_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface MapPinClusterView {
Double getClusterLat();

Double getClusterLng();

String getDiscount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public record PinItemDTO(
double latitude, // 위도 (latitude)
double longitude, // 경도 (longitude)
String pinDetailAddress,
String pinLocation
String pinLocation,
String discount
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public interface MapPinView {
Double getLng(); // ST_X(pin_point) → 경도
String getDetailAddress();
String getRegion(); // location.location 컬럼 (법정동 주소 문자열)
String getDiscount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ private MapPinResDTO.PinItemDTO toDto(MapPinView view) {
view.getLat(),
view.getLng(),
view.getDetailAddress(),
view.getRegion()
view.getRegion(),
view.getDiscount()
);
Comment on lines 88 to 93

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 MapPinViewMapPinClusterView는 대부분의 메서드(getPinId, getPinType, getLat, getLng, getDetailAddress, getRegion, getDiscount)를 공통으로 가지고 있습니다. 이로 인해 MapPinQueryServiceImpl에서 동일한 변환 로직을 가진 toDto 메서드가 중복으로 구현되어 있습니다.

공통 상위 인터페이스를 도입하여 중복 코드를 제거하고 유지보수성을 향상시키는 것을 제안합니다.

적용 예시:

  1. 공통 인터페이스 정의 (MapPinBaseView.java):
public interface MapPinBaseView {
    Long getPinId();
    String getPinType();
    Double getLat();
    Double getLng();
    String getDetailAddress();
    String getRegion();
    String getDiscount();
}
  1. 기존 인터페이스가 상속받도록 수정:
public interface MapPinView extends MapPinBaseView {}

public interface MapPinClusterView extends MapPinBaseView {
    Double getClusterLat();
    Double getClusterLng();
}
  1. MapPinQueryServiceImpl에서 단일 toDto 메서드로 통합:
private MapPinResDTO.PinItemDTO toDto(MapPinBaseView view) {
    return new MapPinResDTO.PinItemDTO(
            view.getPinId(),
            view.getPinType(),
            view.getLat(),
            view.getLng(),
            view.getDetailAddress(),
            view.getRegion(),
            view.getDiscount()
    );
}

}

Expand All @@ -99,7 +100,8 @@ private MapPinResDTO.PinItemDTO toDto(MapPinClusterView view) {
view.getLat(),
view.getLng(),
view.getDetailAddress(),
view.getRegion()
view.getRegion(),
view.getDiscount()
);
}

Expand Down
Loading