-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from SanE-Seo/hongmu
Hongmu
- Loading branch information
Showing
12 changed files
with
344 additions
and
98 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
5 changes: 3 additions & 2 deletions
5
src/main/java/com/seoultech/sanEseo/global/config/DataGoAPI.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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/seoultech/sanEseo/global/config/DataSeoulAPI.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.seoultech.sanEseo.global.config; | ||
|
||
import com.seoultech.sanEseo.weather.application.service.PollutionAPIResponse; | ||
import com.seoultech.sanEseo.weather.application.service.WeatherAPIResponse; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.service.annotation.GetExchange; | ||
|
||
public interface DataSeoulAPI { | ||
|
||
@GetExchange("/{serviceKey}/json/ListAirQualityByDistrictService/1/1/{code}/") | ||
PollutionAPIResponse getPollution( | ||
@PathVariable("serviceKey") String serviceKey, | ||
@PathVariable("code") int code | ||
); | ||
} |
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/seoultech/sanEseo/weather/application/service/PollutionAPIResponse.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,49 @@ | ||
package com.seoultech.sanEseo.weather.application.service; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
public class PollutionAPIResponse { | ||
|
||
@JsonProperty("ListAirQualityByDistrictService") | ||
private ListAirQualityByDistrictService listAirQualityByDistrictService; | ||
|
||
@Data | ||
public static class ListAirQualityByDistrictService { | ||
@JsonProperty("list_total_count") | ||
private int count; | ||
|
||
private List<AirQualityData> row; | ||
} | ||
|
||
@Data | ||
public static class AirQualityData { | ||
@JsonProperty("MSRDATE") | ||
private String date; | ||
@JsonProperty("MSRADMCODE") | ||
private String districtCode; | ||
@JsonProperty("MSRSTENAME") | ||
private String districtName; | ||
@JsonProperty("MAXINDEX") | ||
private String maxIndex; | ||
@JsonProperty("GRADE") | ||
private String grade; | ||
@JsonProperty("POLLUTANT") | ||
private String pollutant; | ||
@JsonProperty("NITROGEN") | ||
private String nitrogen; | ||
@JsonProperty("OZONE") | ||
private String ozone; | ||
@JsonProperty("CARBON") | ||
private String carbon; | ||
@JsonProperty("SULFUROUS") | ||
private String sulfurous; | ||
@JsonProperty("PM10") | ||
private String pm10; | ||
@JsonProperty("PM25") | ||
private String pm25; | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
src/main/java/com/seoultech/sanEseo/weather/application/service/PollutionResponse.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
src/main/java/com/seoultech/sanEseo/weather/application/service/WeatherAPIResponse.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,67 @@ | ||
package com.seoultech.sanEseo.weather.application.service; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
import java.util.List; | ||
|
||
@Data | ||
public class WeatherAPIResponse { | ||
@JsonProperty("response") | ||
private Response response; | ||
|
||
@Data | ||
public static class Response { | ||
private Header header; | ||
private Body body; | ||
} | ||
|
||
@Data | ||
public static class Header { | ||
private String resultCode; | ||
private String resultMsg; | ||
} | ||
|
||
@Data | ||
public static class Body { | ||
private String dataType; | ||
private Items items; | ||
private int pageNo; | ||
private int numOfRows; | ||
private int totalCount; | ||
} | ||
|
||
@Data | ||
public static class Items { | ||
private List<Item> item; | ||
} | ||
|
||
@Data | ||
public static class Item { | ||
private String baseDate; | ||
private String baseTime; | ||
private String category; | ||
private String fcstDate; | ||
private String fcstTime; | ||
private String fcstValue; | ||
private int nx; | ||
private int ny; | ||
} | ||
|
||
public String getValueByCategoryAndDateTime(String category, String fcstDate, String fcstTime) { | ||
for (Item item : response.body.items.item) { | ||
if (item.getCategory().equals(category) && item.getFcstDate().equals(fcstDate) && item.getFcstTime().equals(fcstTime)) { | ||
return item.getFcstValue(); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public String getValueByCategoryAndDate(String category, String fcstDate) { | ||
for (Item item : response.body.items.item) { | ||
if (item.getCategory().equals(category) && item.getFcstDate().equals(fcstDate)) { | ||
return item.getFcstValue(); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.