package com.cyf.devToolBox.controller; import com.cyf.devToolBox.juhe.soup.JuheSoupClient; import com.cyf.devToolBox.juhe.soup.model.JuheSoupResponse; import com.cyf.devToolBox.juhe.weather.JuheWeatherClient; import com.cyf.devToolBox.juhe.weather.model.JuheWeatherResponse; import com.cyf.devToolBox.common.Result; 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; /** * 聚合数据接口,统一返回 {@link Result} 结构。 * *
* GET /api/juhe/weather?city=丰台 查询实时天气(未来天数取配置默认值) * GET /api/juhe/weather?city=北京&futureNum=3 指定未来天气天数 * GET /api/juhe/weather/raw?city=北京 返回原始 JSON,便于排查 * GET /api/juhe/soup 查询每日一句 * GET /api/juhe/soup/raw 返回原始 JSON,便于排查 ** * @author cyf */ @RestController @RequestMapping("/api/juhe") public class JuheController { private final JuheWeatherClient juheWeatherClient; private final JuheSoupClient juheSoupClient; public JuheController(JuheWeatherClient juheWeatherClient, JuheSoupClient juheSoupClient) { this.juheWeatherClient = juheWeatherClient; this.juheSoupClient = juheSoupClient; } /** * 查询指定城市的天气。 * * @param city 城市名称(中文),如:北京、丰台 * @param futureNum 未来天气天数(1~7),不传则使用配置中的默认值 * @return 统一返回结构,data 为天气数据 */ @GetMapping("/weather") public Result