From 2edf8f5847bcc121a35c9aaee5531585e6b923f5 Mon Sep 17 00:00:00 2001
From: fengjin <1435304038@qq.com>
Date: 星期三, 23 十一月 2022 13:55:35 +0800
Subject: [PATCH] 1.更改系统设置更改问题 2.新增导半人员设置创建人 3.搜索sql优化

---
 flower_city/src/main/java/com/dg/core/controller/CommonController.java |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/flower_city/src/main/java/com/dg/core/controller/CommonController.java b/flower_city/src/main/java/com/dg/core/controller/CommonController.java
index 12fa193..df34391 100644
--- a/flower_city/src/main/java/com/dg/core/controller/CommonController.java
+++ b/flower_city/src/main/java/com/dg/core/controller/CommonController.java
@@ -2,6 +2,8 @@
 
 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;
@@ -17,6 +19,7 @@
 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;
@@ -54,6 +57,9 @@
     private int port;
     @Value("${ftp.url}")
     private String url;
+
+    @Resource
+    RedisTemplate<String, Object> redisTemplate;
 
 
     @RequestMapping("/hello")
@@ -98,6 +104,7 @@
         return ResultData.success(ajax);
 
     }
+
 
 
     /**
@@ -151,7 +158,6 @@
             return success("工作日");
     }
 
-
     /**
      * 获取天气默认为攀枝花
      */
@@ -160,12 +166,12 @@
     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);
     }
 
 

--
Gitblit v1.7.1