Commit c83330f9 authored by maoying's avatar maoying

修改获取天气预报接口

parent 8166302b
...@@ -7,13 +7,13 @@ import java.net.URLConnection; ...@@ -7,13 +7,13 @@ import java.net.URLConnection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
...@@ -25,6 +25,10 @@ import io.swagger.annotations.ApiOperation; ...@@ -25,6 +25,10 @@ import io.swagger.annotations.ApiOperation;
@Api(tags="天气api") @Api(tags="天气api")
public class WeatherController extends BaseController { public class WeatherController extends BaseController {
@Value("${param.weather.url}")
private String weatherUrl;
@ApiOperation(httpMethod = "GET",value = "天气查询", notes = "天气查询") @ApiOperation(httpMethod = "GET",value = "天气查询", notes = "天气查询")
@GetMapping("/{address}") @GetMapping("/{address}")
public CommonResponse getWeather(@PathVariable("address") String address) { public CommonResponse getWeather(@PathVariable("address") String address) {
...@@ -32,7 +36,7 @@ public class WeatherController extends BaseController { ...@@ -32,7 +36,7 @@ public class WeatherController extends BaseController {
String result = ""; String result = "";
BufferedReader in = null; BufferedReader in = null;
try { try {
String urlNameString = "http://t.weather.sojson.com/api/weather/city/" + address; String urlNameString = weatherUrl + address;
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接 // 打开和URL之间的连接
......
...@@ -49,5 +49,8 @@ linux.img.path = / ...@@ -49,5 +49,8 @@ linux.img.path = /
param.safetyIndexChange.cron = 0 0 2 * * ? param.safetyIndexChange.cron = 0 0 2 * * ?
#获取天气地址
param.weather.url = http://t.weather.sojson.com/api/weather/city/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment