Skip to content

Commit d2e73fe

Browse files
committed
feat: fe분들이 원하는 내용으로 제조중
1 parent fd51c06 commit d2e73fe

6 files changed

Lines changed: 124 additions & 5 deletions

File tree

src/main/java/com/back/web7_9_codecrete_be/domain/location/controller/KakaoApiController.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoLocalResponse;
44
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoMobilityResponse;
5+
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoRouteTransitResponse;
56
import com.back.web7_9_codecrete_be.domain.location.service.KakaoLocalService;
67
import com.back.web7_9_codecrete_be.global.error.code.LocationErrorCode;
78
import com.back.web7_9_codecrete_be.global.error.exception.BusinessException;
@@ -117,5 +118,28 @@ public KakaoMobilityResponse.Summary navigateSummary(
117118
return route0.getSummary();
118119

119120
}
121+
122+
@PostMapping("/navigate/onlyguide")
123+
public List<KakaoRouteTransitResponse.Guide> navigateOnlyGuides(
124+
@RequestParam double startX,
125+
@RequestParam double startY,
126+
@RequestParam double endX,
127+
@RequestParam double endY,
128+
@RequestParam double wayX,
129+
@RequestParam double wayY
130+
) {
131+
KakaoRouteTransitResponse res = kakaoLocalService.NaviSearchTransit(startX, startY, endX, endY, wayX, wayY);
132+
133+
if (res == null || res.getRoutes() == null || res.getRoutes().isEmpty()) {
134+
return List.of();
135+
}
136+
137+
KakaoRouteTransitResponse.Route route0 = res.getRoutes().get(0);
138+
139+
return route0.getSections().stream()
140+
.filter(section -> section.getGuides() != null && !section.getGuides().isEmpty())
141+
.flatMap(section -> section.getGuides().stream())
142+
.toList();
143+
}
120144
}
121145

src/main/java/com/back/web7_9_codecrete_be/domain/location/dto/response/TmapRequest.java renamed to src/main/java/com/back/web7_9_codecrete_be/domain/location/dto/request/TmapRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.back.web7_9_codecrete_be.domain.location.dto.response;
1+
package com.back.web7_9_codecrete_be.domain.location.dto.request;
22

33
import io.swagger.v3.oas.annotations.media.Schema;
44
import lombok.Data;

src/main/java/com/back/web7_9_codecrete_be/domain/location/dto/response/KakaoMobilityResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static class Road{
3939

4040

4141
@Getter
42-
public static class Guide { // ✅ 추가
42+
public static class Guide {
4343
private String name;
4444
private double x;
4545
private double y;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.back.web7_9_codecrete_be.domain.location.dto.response;
2+
3+
import lombok.Getter;
4+
import java.util.List;
5+
6+
@Getter
7+
public class KakaoRouteTransitResponse {
8+
9+
private List<Route> routes;
10+
11+
@Getter
12+
public static class Route {
13+
private Summary summary;
14+
private List<Section> sections;
15+
}
16+
17+
@Getter
18+
public static class Summary {
19+
private Origin origin;
20+
private Destination destination;
21+
private List<Waypoint> waypoints; // ✅ 경유지(요청값)
22+
23+
private String priority;
24+
private Fare fare;
25+
26+
private int distance; // meters
27+
private int duration; // seconds
28+
}
29+
30+
@Getter
31+
public static class Origin {
32+
private String name;
33+
private double x;
34+
private double y;
35+
}
36+
37+
@Getter
38+
public static class Destination {
39+
private String name;
40+
private double x;
41+
private double y;
42+
}
43+
44+
@Getter
45+
public static class Waypoint {
46+
private String name;
47+
private double x;
48+
private double y;
49+
}
50+
51+
@Getter
52+
public static class Fare {
53+
private int taxi;
54+
private int toll;
55+
}
56+
57+
@Getter
58+
public static class Section {
59+
private List<Road> roads;
60+
private List<Guide> guides;
61+
}
62+
63+
@Getter
64+
public static class Road {
65+
private List<Double> vertexes;
66+
}
67+
68+
@Getter
69+
public static class Guide {
70+
private String name;
71+
private double x;
72+
private double y;
73+
private int distance;
74+
private int duration;
75+
private int type;
76+
private String guidance;
77+
private int road_index;
78+
}
79+
}

src/main/java/com/back/web7_9_codecrete_be/domain/location/service/KakaoLocalService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.back.web7_9_codecrete_be.domain.location.dto.KakaoCoordinateResponse;
44
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoLocalResponse;
55
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoMobilityResponse;
6+
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoRouteTransitResponse;
67
import com.back.web7_9_codecrete_be.global.error.code.LocationErrorCode;
78
import com.back.web7_9_codecrete_be.global.error.exception.BusinessException;
89
import lombok.RequiredArgsConstructor;
@@ -129,4 +130,21 @@ public KakaoMobilityResponse NaviSearchSummary(double startX, double startY, dou
129130

130131
return response;
131132
}
133+
134+
public KakaoRouteTransitResponse NaviSearchTransit(double startX, double startY
135+
, double endX, double endY, double wayX, double wayY){
136+
KakaoRouteTransitResponse response = kakaoMobilityClient.post()
137+
.uri(uriBuilder -> uriBuilder
138+
.path("/v1/waypoints/directions")
139+
.queryParam("origin", startX + "," + startY)
140+
.queryParam("destination", endX + "," + endY)
141+
.queryParam("waypoints", wayX + "," + wayY)
142+
.queryParam("priority", "TIME")
143+
.queryParam("summary", "false")
144+
.build()
145+
)
146+
.retrieve()
147+
.body(KakaoRouteTransitResponse.class);
148+
return response;
149+
}
132150
}

src/main/java/com/back/web7_9_codecrete_be/domain/location/service/TmapService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.back.web7_9_codecrete_be.domain.location.service;
22

3-
import com.back.web7_9_codecrete_be.domain.location.dto.response.TmapRequest;
3+
import com.back.web7_9_codecrete_be.domain.location.dto.request.TmapRequest;
44
import com.back.web7_9_codecrete_be.domain.location.dto.request.TmapSummaryRequest;
55
import com.back.web7_9_codecrete_be.domain.location.dto.response.TmapSummaryAllResponse;
6-
import com.back.web7_9_codecrete_be.domain.location.dto.response.TmapSummaryResponse;
7-
import lombok.RequiredArgsConstructor;
86
import org.springframework.beans.factory.annotation.Qualifier;
97
import org.springframework.http.MediaType;
108
import org.springframework.stereotype.Service;

0 commit comments

Comments
 (0)