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