날씨
This commit is contained in:
parent
a0cac0b987
commit
dd31e08c4f
@ -1,12 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID">
|
||||
<display-name>localhost</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
|
||||
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<display-name>localhost</display-name>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
|
||||
@ -30,12 +30,13 @@ public class MapBasedUrlRoleMapper implements UrlRoleMapper{
|
||||
public Map<String, String> getUrlRoleMappings() {
|
||||
urlRoleMappings.put("/api/user/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/project/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/vacation/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/board/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/vote/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/worddict/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/quilleditor/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/commuters/**", PERMIT_ALL);
|
||||
urlRoleMappings.put("/api/vacation/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/board/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/vote/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/worddict/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/quilleditor/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/commuters/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/weather/**", ROLE_MEMBER);
|
||||
urlRoleMappings.put("/api/admin/**", PERMIT_ALL);
|
||||
return new HashMap<>(urlRoleMappings);
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
package io.company.localhost.controller.common;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import io.company.localhost.common.dto.ApiResponse;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/weather")
|
||||
public class WeatherController {
|
||||
|
||||
@Value("${api.weather.key}")
|
||||
private String weatherApiKey;
|
||||
|
||||
@GetMapping
|
||||
public ApiResponse<String> getWeather(@RequestParam("lat") double lat,@RequestParam("lon") double lon) {
|
||||
String url = String.format(
|
||||
"https://api.openweathermap.org/data/2.5/forecast?lat=%f&lon=%f&appid=%s&units=metric&lang=kr",
|
||||
lat, lon, weatherApiKey
|
||||
);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String response = restTemplate.getForObject(url, String.class);
|
||||
|
||||
return ApiResponse.ok(response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,8 @@ management:
|
||||
api:
|
||||
public-holiday:
|
||||
key: "MugzCRZ7VmR/LJ3BZ1Ehmmg5yiI0GPFt4evLjNkNuwKoiWbKbe/M9U5pLjAxfSP13OOwHi943aMFM9yiI8OADA=="
|
||||
|
||||
weather:
|
||||
key: "3505b3500aacf34c4497bf449996ea09"
|
||||
|
||||
server:
|
||||
shutdown: graceful
|
||||
|
||||
Loading…
Reference in New Issue
Block a user