| | |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.dg.core.CorsConfig; |
| | | import com.dg.core.ResultData; |
| | | import com.dg.core.db.gen.AjaxResult; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private int port; |
| | | @Value("${ftp.url}") |
| | | private String url; |
| | | |
| | | @Resource |
| | | RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | |
| | | @RequestMapping("/hello") |
| | |
| | | return ResultData.success(ajax); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return success("工作日"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取天气默认为攀枝花 |
| | | */ |
| | |
| | | public ResultData getWeather(@RequestParam(value = "code", required = false) String code) { |
| | | TestDate td = new TestDate(); |
| | | Map weather; |
| | | if (code == null) { |
| | | weather = td.getWeather("510400"); |
| | | if (code == null) {//默认为攀枝花 则从redis上获取redis上定时任务15分钟获取一次天气 |
| | | HashMap weather1 = (HashMap) redisTemplate.opsForValue().get("weather"); |
| | | return ResultData.success(weather1.get("lives")); |
| | | } else { |
| | | weather = td.getWeather(code); |
| | | return ResultData.success(td.getWeather(code)); |
| | | } |
| | | return ResultData.success(weather); |
| | | } |
| | | |
| | | |