소스정리
This commit is contained in:
@@ -35,8 +35,4 @@ public class MainController {
|
||||
public Map<String, Object> listData(BodArti srch) throws JsonDataException {
|
||||
return HttpUtil.responseList(bodArtiService.selectList(srch));
|
||||
}
|
||||
@GetMapping("/sync-station")
|
||||
public Object syncStation() {
|
||||
return stationService.getStations();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import org.springframework.web.client.RestClient;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@@ -18,13 +19,14 @@ public class ApiClient {
|
||||
|
||||
public ApiResponse<List<StationDto>> fetchStations(String baseUrl, String token) {
|
||||
URI uri = UriComponentsBuilder.fromUriString(baseUrl)
|
||||
.path("/api/station/list")
|
||||
.path("/api/st/list")
|
||||
.build()
|
||||
.toUri();
|
||||
|
||||
return restClient.get()
|
||||
return restClient.post()
|
||||
.uri(uri)
|
||||
.header("Authorization", "Bearer " + token)
|
||||
.body(Collections.emptyMap())
|
||||
.retrieve()
|
||||
.body(new ParameterizedTypeReference<ApiResponse<List<StationDto>>>() {});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.jwsi.jcms.vpp.station;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.Getter;
|
||||
@@ -12,20 +13,50 @@ import net.jwsi.jcms.base.BaseStEntity;
|
||||
@NoArgsConstructor
|
||||
@Entity(name="vpp_station")
|
||||
public class Station extends BaseStEntity {
|
||||
|
||||
@Id
|
||||
@Column(name = "st_id")
|
||||
private String stationId;
|
||||
|
||||
@Column(name = "PROVIDER_ID")
|
||||
private String providerId;
|
||||
|
||||
@Column(name = "ST_NM")
|
||||
private String stNm;
|
||||
|
||||
@Column(name = "ADDR_RD_M")
|
||||
private String addrRdM;
|
||||
|
||||
@Column(name = "ADDR_RD_D")
|
||||
private String addrRdD;
|
||||
|
||||
@Column(name = "ADDR_LD_M")
|
||||
private String addrLdM;
|
||||
|
||||
@Column(name = "ADDR_LD_D")
|
||||
private String addrLdD;
|
||||
|
||||
@Column(name = "st_facil_tp_cd")
|
||||
private String stFacilTpCd;
|
||||
|
||||
@Column(name = "st_facil_d_tp_cd")
|
||||
private String stFacilDTpCd;
|
||||
|
||||
@Column(name = "parking_fee_yn")
|
||||
private String parkingFeeYn;
|
||||
|
||||
@Column(name = "PARKING_FEE_DETL")
|
||||
private String parkingFeeDetl;
|
||||
|
||||
@Column(name = "pnu_no")
|
||||
private String pnuNo;
|
||||
|
||||
@Column(name = "PNU_DO_NM")
|
||||
private String pnuDoNm;
|
||||
|
||||
@Column(name = "PNU_DONG_NM")
|
||||
private String pnuDongNm;
|
||||
|
||||
@Column(name = "PNU_SI_NM")
|
||||
private String pnuSiNm;
|
||||
}
|
||||
@@ -6,39 +6,31 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class StationDto {
|
||||
private String stationId;
|
||||
private String providerId;
|
||||
private String stId;
|
||||
private String stNm;
|
||||
private String addrRdM;
|
||||
private String addrRdD;
|
||||
private String addrLdM;
|
||||
private String addrLdD;
|
||||
private String stFacilTpCd;
|
||||
private String stFacilDTpCd;
|
||||
private String parkingFeeYn;
|
||||
private String addrRd;
|
||||
private String addrLd;
|
||||
private String stFacilTp;
|
||||
private String stFacilDTp;
|
||||
private String parkingFee;
|
||||
private String parkingFeeDetl;
|
||||
private String pnuNo;
|
||||
private String pnuDoNm;
|
||||
private String pnuDongNm;
|
||||
private String pnuSiNm;
|
||||
private String pnuNm;
|
||||
|
||||
public Station toEntity() {
|
||||
Station station = new Station();
|
||||
station.setStationId(this.stationId);
|
||||
station.setStationId(this.stId);
|
||||
station.setProviderId(this.providerId);
|
||||
station.setStNm(this.stNm);
|
||||
station.setAddrRdM(this.addrRdM);
|
||||
station.setAddrRdD(this.addrRdD);
|
||||
station.setAddrLdM(this.addrLdM);
|
||||
station.setAddrLdD(this.addrLdD);
|
||||
station.setStFacilTpCd(this.stFacilTpCd);
|
||||
station.setStFacilDTpCd(this.stFacilDTpCd);
|
||||
station.setParkingFeeYn(this.parkingFeeYn);
|
||||
station.setAddrRdM(this.addrRd);
|
||||
station.setAddrLdM(this.addrLd);
|
||||
station.setStFacilTpCd(this.stFacilTp);
|
||||
station.setStFacilDTpCd(this.stFacilDTp);
|
||||
station.setParkingFeeYn(this.parkingFee);
|
||||
station.setParkingFeeDetl(this.parkingFeeDetl);
|
||||
station.setPnuNo(this.pnuNo);
|
||||
station.setPnuDoNm(this.pnuDoNm);
|
||||
station.setPnuDongNm(this.pnuDongNm);
|
||||
station.setPnuSiNm(this.pnuSiNm);
|
||||
station.setPnuDoNm(this.pnuNm);
|
||||
return station;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.jwsi.jcms.utils.HttpUtil;
|
||||
import net.jwsi.jcms.utils.LoginUtil;
|
||||
import net.jwsi.jcms.vpp.api.ApiResponse;
|
||||
import net.jwsi.jcms.vpp.api.ApiClient;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -21,19 +22,20 @@ import java.util.stream.Collectors;
|
||||
public class StationService extends BaseService<Station,String,StationRepository> {
|
||||
|
||||
private final ApiClient apiClient;
|
||||
private final String API_TOKEN = System.getenv("API_TOKEN");
|
||||
@Value("${jcms.api.base-url}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${jcms.api.token}")
|
||||
private String apiToken;
|
||||
public StationService(StationRepository repository, ApiClient apiClient) {
|
||||
super(repository);
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<Station> getStations() {
|
||||
String baseUrl = "http://dev.jinwoosi.co.kr:8072/api/st/list";
|
||||
|
||||
ApiResponse<List<StationDto>> response = apiClient.fetchStations(baseUrl, API_TOKEN);
|
||||
ApiResponse<List<StationDto>> response = apiClient.fetchStations(baseUrl, apiToken);
|
||||
|
||||
if (response == null || !Integer.valueOf(200).equals(response.getCode())) {
|
||||
String msg = (response != null) ? response.getMessage() : "응답 없음";
|
||||
|
||||
@@ -32,7 +32,5 @@ jcms:
|
||||
enabled: true
|
||||
days: 30
|
||||
api:
|
||||
path: /api
|
||||
key:
|
||||
prefix: ak_
|
||||
header-name: X-API-KEY
|
||||
base-url: ${API_BASE_URL:http://dev.jinwoosi.co.kr:8072}
|
||||
token: ${API_TOKEN}
|
||||
Reference in New Issue
Block a user