Skip to content

Commit

Permalink
fix: 외부 API 필드 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jcw1031 committed Nov 14, 2024
1 parent 69526c4 commit 43d4735
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ElevatorLocation {
@JsonAlias(value = "NODE_WKT")
private String wellKnowText;

@JsonAlias(value = "SW_NM")
@JsonAlias(value = "SBWY_STN_NM")
private String stationName;

public Coordinate extractCoordinate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ElevatorStatusInfo {

@JsonAlias(value = "STATION_NM")
@JsonAlias(value = "STN_NM")
private String stationName;

@JsonAlias(value = "FACI_NM")
@JsonAlias(value = "ELVTR_NM")
private String elevatorName;

@JsonAlias(value = "STUP_LCTN")
@JsonAlias(value = "OPR_SEC")
private String elevatorFloor;

@JsonAlias(value = "LOCATION")
@JsonAlias(value = "INSTL_PSTN")
private String location;

@JsonAlias(value = "USE_YN")
private String status;

@JsonAlias(value = "GUBUN")
@JsonAlias(value = "ELVTR_SE")
private String category;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class StationContact {

@JsonAlias(value = "LINE")
@JsonAlias(value = "SBWY_ROUT_LN")
private String lineName;

@JsonAlias(value = "STATN_NM")
@JsonAlias(value = "SBWY_STNS_NM")
private String stationName;

@JsonAlias(value = "TELNO")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class StationImage {

@JsonAlias(value = "STN_NM")
@JsonAlias(value = "STTN")
private String stationName;

@JsonAlias(value = "STN_LINE")
@JsonAlias(value = "SBWY_ROUT_LN")
private String lineId;

@JsonAlias(value = "STN_IMG_URL")
@JsonAlias(value = "IMG_LINK")
private String stationImageUrl;
}
7 changes: 4 additions & 3 deletions src/main/java/team/free/freeway/init/ElevatorInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import team.free.freeway.api.SeoulOpenAPIManager;
import team.free.freeway.api.dto.value.ElevatorLocation;
import team.free.freeway.api.dto.value.ElevatorStatusInfo;
Expand Down Expand Up @@ -49,8 +50,8 @@ private Map<String, List<ElevatorLocation>> createElevatorLocationMap(List<Eleva
continue;
}

List<ElevatorLocation> specificElevatorLocationList =
elevatorLocationMap.getOrDefault(stationName, new ArrayList<>());
List<ElevatorLocation> specificElevatorLocationList = elevatorLocationMap
.getOrDefault(stationName, new ArrayList<>());
specificElevatorLocationList.add(elevatorLocation);
elevatorLocationMap.put(stationName, specificElevatorLocationList);
}
Expand All @@ -60,7 +61,7 @@ private Map<String, List<ElevatorLocation>> createElevatorLocationMap(List<Eleva

private void mappingStationAndElevator(Map<String, List<ElevatorLocation>> elevatorLocationMap, Station station) {
List<ElevatorLocation> elevatorLocationList = elevatorLocationMap.get(station.getName());
if (elevatorLocationList == null || elevatorLocationList.isEmpty()) {
if (CollectionUtils.isEmpty(elevatorLocationList)) {
return;
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/team/free/freeway/init/StationInitializer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package team.free.freeway.init;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
Expand Down Expand Up @@ -28,13 +29,14 @@
import static team.free.freeway.init.constant.StationExcelIndex.LINE_NAME_INDEX;
import static team.free.freeway.init.constant.StationExcelIndex.STATION_NAME_INDEX;

@Slf4j
@Transactional
@RequiredArgsConstructor
@Component
public class StationInitializer {

private static final String STATION_CODE_INFO_PATH = "/Users/jcw/Develop/Free-Way/src/main/resources/station_code.xlsx";
private static final String NEXT_STATION_INFO_PATH = "/Users/jcw/Develop/Free-Way/src/main/resources/next_station.xlsx";
private static final String STATION_CODE_INFO_PATH = "/Users/jcw1031/Develop/TeamProject/Free-Way/src/main/resources/station_code.xlsx";
private static final String NEXT_STATION_INFO_PATH = "/Users/jcw1031/Develop/TeamProject/Free-Way/src/main/resources/next_station.xlsx";

private final KakaoAPIManager kakaoAPIManager;
private final StationRepository stationRepository;
Expand All @@ -51,8 +53,9 @@ public void initializeStation() throws IOException {
String stationName = row.getCell(STATION_NAME_INDEX).toString();
stationName = StationNameUtils.getPureStationName(stationName);

log.info("지하철역 이름: {}, 호선: {}", stationName, lineName);
Location location = kakaoAPIManager.getStationLocationInfo(stationName, lineName);
if (!location.getAddress().startsWith("서울")) {
if (location == null || !location.getAddress().startsWith("서울")) {
continue;
}

Expand Down

0 comments on commit 43d4735

Please sign in to comment.