-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#59
- Loading branch information
Showing
37 changed files
with
1,030 additions
and
140 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
5 changes: 5 additions & 0 deletions
5
server/src/main/java/com/talkka/server/api/core/config/ApiKeyProperty.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,5 @@ | ||
package com.talkka.server.api.core.config; | ||
|
||
public interface ApiKeyProperty { | ||
String getApiKey(); | ||
} |
27 changes: 27 additions & 0 deletions
27
server/src/main/java/com/talkka/server/api/datagg/config/BusApiKeyProperty.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,27 @@ | ||
package com.talkka.server.api.datagg.config; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.talkka.server.api.core.config.ApiKeyProperty; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Component | ||
@ConfigurationProperties(prefix = "openapi.public.bus.service-key") | ||
public class BusApiKeyProperty implements ApiKeyProperty { | ||
@Setter | ||
private List<String> keys; | ||
|
||
private int rollingKeyIndex = 0; | ||
|
||
@Override | ||
public String getApiKey() { | ||
rollingKeyIndex = (rollingKeyIndex + 1) % keys.size(); | ||
return keys.get(rollingKeyIndex); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
server/src/main/java/com/talkka/server/api/datagg/dto/BusLocationBodyDto.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,8 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
@JacksonXmlRootElement(localName = "busLocationList") | ||
public record BusLocationBodyDto(String endBus, String lowPlate, String plateNo, String plateType, | ||
Integer remainSeatCnt, Long routeId, Long stationId, Integer stationSeq) { | ||
} |
14 changes: 14 additions & 0 deletions
14
server/src/main/java/com/talkka/server/api/datagg/dto/BusLocationRespDto.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,14 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
@JacksonXmlRootElement(localName = "response") | ||
public record BusLocationRespDto(@JacksonXmlProperty(localName = "comMsgHeader") Map<String, String> comMsgHeader, | ||
@JacksonXmlProperty(localName = "msgHeader") Map<String, String> msgHeader, | ||
@JacksonXmlProperty(localName = "msgBody") List<BusLocationBodyDto> msgBody) | ||
implements PublicBusApiResp<BusLocationBodyDto> { | ||
} |
28 changes: 28 additions & 0 deletions
28
server/src/main/java/com/talkka/server/api/datagg/dto/BusRouteInfoBodyDto.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,28 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
@JacksonXmlRootElement(localName = "busRouteInfoItem") | ||
public record BusRouteInfoBodyDto( | ||
String companyId, // 운수업체 아이디 | ||
String companyName, // 운수업체명 | ||
String companyTel, // 운수업체 전화번호 | ||
int districtCd, // 관할 지역 코드 | ||
String downFirstTime, // 평일 종점 첫차 시간 | ||
String downLastTime, // 평일 종점 막차 시간 | ||
Long endStationId, // 종점 정류소 아이디 | ||
String endStationName, // 종점 정류소명 | ||
int peekAlloc, // 평일 최소 배차 시간 | ||
String regionName, // 지역명 | ||
Long routeId, // 노선 아이디 | ||
String routeName, // 노선 번호 | ||
int routeTypeCd, // 노선 유형 코드 | ||
String routeTypeName, // 노선 유형명 | ||
String startMobileNo, // 기점 정류소 번호 | ||
Long startStationId, // 기점 정류소 아이디 | ||
String startStationName, // 기점 정류소명 | ||
String upFirstTime, // 평일 기점 첫차 시간 | ||
String upLastTime, // 평일 기점 막차 시간 | ||
int nPeekAlloc // 평일 최대 배차 시간 | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
server/src/main/java/com/talkka/server/api/datagg/dto/BusRouteInfoRespDto.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,14 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
@JacksonXmlRootElement(localName = "response") | ||
public record BusRouteInfoRespDto(@JacksonXmlProperty(localName = "comMsgHeader") Map<String, String> comMsgHeader, | ||
@JacksonXmlProperty(localName = "msgHeader") Map<String, String> msgHeader, | ||
@JacksonXmlProperty(localName = "msgBody") List<BusRouteInfoBodyDto> msgBody) | ||
implements PublicBusApiResp<BusRouteInfoBodyDto> { | ||
} |
15 changes: 15 additions & 0 deletions
15
server/src/main/java/com/talkka/server/api/datagg/dto/BusRouteSearchBodyDto.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,15 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
/** | ||
* @param routeId 노선 아이디 | ||
* @param routeName 노선 번호 | ||
* @param routeTypeCd 노선 유형 코드 | ||
* @param routeTypeName 노선 유형명 | ||
* @param regionName 노선 운행 지역 | ||
* @param districtCd 노선 관할 지역 코드 */ | ||
@JacksonXmlRootElement(localName = "busRouteList") | ||
public record BusRouteSearchBodyDto(Long routeId, String routeName, String routeTypeCd, String routeTypeName, | ||
String regionName, int districtCd) { | ||
} |
14 changes: 14 additions & 0 deletions
14
server/src/main/java/com/talkka/server/api/datagg/dto/BusRouteSearchRespDto.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,14 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
@JacksonXmlRootElement(localName = "response") | ||
public record BusRouteSearchRespDto(@JacksonXmlProperty(localName = "comMsgHeader") Map<String, String> comMsgHeader, | ||
@JacksonXmlProperty(localName = "msgHeader") Map<String, String> msgHeader, | ||
@JacksonXmlProperty(localName = "msgBody") List<BusRouteSearchBodyDto> msgBody) | ||
implements PublicBusApiResp<BusRouteSearchBodyDto> { | ||
} |
20 changes: 20 additions & 0 deletions
20
server/src/main/java/com/talkka/server/api/datagg/dto/BusRouteStationBodyDto.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.talkka.server.api.datagg.dto; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
/** | ||
* @param stationId 정류소 아이디 | ||
* @param stationSeq 정류소 순번 | ||
* @param stationName 정류소 명칭 | ||
* @param mobileNo 정류소 고유 모바일 번호 | ||
* @param regionName 정류소 위치 지역명 | ||
* @param districtCd 노선 관할 지역 코드 | ||
* @param centerYn 중앙차로 여부 (N: 일반, Y: 중앙차로) | ||
* @param turnYn 회차점 여부 (N: 일반, Y: 회차점) | ||
* @param x 정류소 X 좌표 | ||
* @param y 정류소 Y 좌표 */ | ||
@JacksonXmlRootElement(localName = "busRouteStationList") | ||
public record BusRouteStationBodyDto(Long stationId, Integer stationSeq, String stationName, String mobileNo, | ||
String regionName, String districtCd, String centerYn, String turnYn, Double x, | ||
Double y) { | ||
} |
14 changes: 14 additions & 0 deletions
14
server/src/main/java/com/talkka/server/api/datagg/dto/BusRouteStationRespDto.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,14 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||
|
||
@JacksonXmlRootElement(localName = "response") | ||
public record BusRouteStationRespDto(@JacksonXmlProperty(localName = "comMsgHeader") Map<String, String> comMsgHeader, | ||
@JacksonXmlProperty(localName = "msgHeader") Map<String, String> msgHeader, | ||
@JacksonXmlProperty(localName = "msgBody") List<BusRouteStationBodyDto> msgBody) | ||
implements PublicBusApiResp<BusRouteStationBodyDto> { | ||
} |
12 changes: 12 additions & 0 deletions
12
server/src/main/java/com/talkka/server/api/datagg/dto/PublicBusApiResp.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,12 @@ | ||
package com.talkka.server.api.datagg.dto; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface PublicBusApiResp<T> { | ||
Map<String, String> comMsgHeader(); | ||
|
||
Map<String, String> msgHeader(); | ||
|
||
List<T> msgBody(); | ||
} |
20 changes: 20 additions & 0 deletions
20
server/src/main/java/com/talkka/server/api/datagg/service/BusApiService.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.talkka.server.api.datagg.service; | ||
|
||
import java.util.List; | ||
|
||
import com.talkka.server.api.datagg.dto.BusLocationBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteInfoBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteSearchBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteStationBodyDto; | ||
|
||
public interface BusApiService { | ||
List<BusRouteSearchBodyDto> getSearchedRouteInfo(String routeName); | ||
|
||
List<BusRouteInfoBodyDto> getRouteInfo(String apiRouteId); | ||
|
||
List<BusRouteStationBodyDto> getRouteStationInfo(String apiRouteId); | ||
|
||
List<BusLocationBodyDto> getBusLocationInfo(String apiRouteId); | ||
|
||
// List<RouteBusStationArrivalInfoRespDto> getBusStationArrivalInfo(String routeId); | ||
} |
88 changes: 88 additions & 0 deletions
88
server/src/main/java/com/talkka/server/api/datagg/service/BusApiServiceImpl.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,88 @@ | ||
package com.talkka.server.api.datagg.service; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.client.RestTemplate; | ||
import org.springframework.web.util.DefaultUriBuilderFactory; | ||
|
||
import com.talkka.server.api.datagg.config.BusApiKeyProperty; | ||
import com.talkka.server.api.datagg.dto.BusLocationBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusLocationRespDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteInfoBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteInfoRespDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteSearchBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteSearchRespDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteStationBodyDto; | ||
import com.talkka.server.api.datagg.dto.BusRouteStationRespDto; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BusApiServiceImpl implements BusApiService { | ||
private final BusApiKeyProperty busApiKeyProperty; | ||
private final RestTemplate restTemplate = new RestTemplate(); | ||
private static final String host = "apis.data.go.kr"; | ||
|
||
@Override | ||
public List<BusRouteSearchBodyDto> getSearchedRouteInfo(String keyword) { | ||
final String path = "/6410000/busrouteservice/getBusRouteList"; | ||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); | ||
params.add("keyword", keyword); | ||
URI uri = this.getOpenApiURI(path, params); | ||
ResponseEntity<BusRouteSearchRespDto> resp = restTemplate.getForEntity(uri, BusRouteSearchRespDto.class); | ||
return resp.getBody().msgBody(); | ||
} | ||
|
||
@Override | ||
public List<BusRouteInfoBodyDto> getRouteInfo(String apiRouteId) { | ||
final String path = "/6410000/busrouteservice/getBusRouteInfoItem"; | ||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); | ||
params.add("routeId", apiRouteId); | ||
URI uri = this.getOpenApiURI(path, params); | ||
ResponseEntity<BusRouteInfoRespDto> resp = restTemplate.getForEntity(uri, BusRouteInfoRespDto.class); | ||
return resp.getBody().msgBody(); | ||
} | ||
|
||
@Override | ||
public List<BusRouteStationBodyDto> getRouteStationInfo(String apiRouteId) { | ||
final String path = "/6410000/busrouteservice/getBusRouteStationList"; | ||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); | ||
params.add("routeId", apiRouteId); | ||
URI uri = this.getOpenApiURI(path, params); | ||
ResponseEntity<BusRouteStationRespDto> resp = restTemplate.getForEntity(uri, BusRouteStationRespDto.class); | ||
return resp.getBody().msgBody(); | ||
} | ||
|
||
@Override | ||
public List<BusLocationBodyDto> getBusLocationInfo(String apiRouteId) { | ||
final String path = "/6410000/buslocationservice/getBusLocationList"; | ||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); | ||
params.add("routeId", apiRouteId); | ||
URI uri = this.getOpenApiURI(path, params); | ||
ResponseEntity<BusLocationRespDto> resp = restTemplate.getForEntity(uri, BusLocationRespDto.class); | ||
return resp.getBody().msgBody(); | ||
} | ||
|
||
// @Override | ||
// public List<RouteBusStationArrivalInfoRespDto> getBusStationArrivalInfo(String routeId) { | ||
// return null; | ||
// } | ||
|
||
private URI getOpenApiURI(String path, MultiValueMap<String, String> params) { | ||
final var builder = new DefaultUriBuilderFactory(); | ||
builder.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE); | ||
return builder.builder() | ||
.scheme("https") | ||
.host(host) | ||
.path(path) | ||
.queryParam("serviceKey", this.busApiKeyProperty.getApiKey()) | ||
.queryParams(params) | ||
.build(); | ||
} | ||
} |
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
Oops, something went wrong.