rkljw 3 天之前
父節點
當前提交
675c132114

+ 14 - 1
app/JsonRpc/PublicRpcService.php

@@ -658,7 +658,7 @@ class PublicRpcService implements PublicRpcServiceInterface
             return Result::success($ip_info);
         } else {
             $data['ip'] = '101.254.114.212';
-            $this->getIpinfo($data['ip']);
+            $this->getIpinfo(["ip"=>$data['ip']]);
         }
     }
 
@@ -669,6 +669,17 @@ class PublicRpcService implements PublicRpcServiceInterface
      */
     public function getWeatherInfo(array $data) :array
     {
+        $month = $data['month'] ?? date('m');
+        $day = $data['day'] ?? date('d');
+        // 使用缓存键
+        $cacheKey = "tsbb_data_weather_{$month}_{$day}";
+        
+        // 尝试从缓存获取数据
+        $container = \Hyperf\Context\ApplicationContext::getContainer();
+        $cache = $container->get(\Psr\SimpleCache\CacheInterface::class);
+        if ($cachedData = $cache->get($cacheKey)) {
+            return Result::success(unserialize($cachedData));
+        }
         $location = $data['latitude'].":".$data['longitude'];
         $api_url = "https://api.seniverse.com/v3/weather/now.json?key=".\Hyperf\Support\env('WEATHER_KEY')."&location=".$location."&language=zh-Hans&unit=c";
         $ch = curl_init($api_url);
@@ -677,6 +688,8 @@ class PublicRpcService implements PublicRpcServiceInterface
         curl_close($ch);
         // 解析 JSON 响应
         $WeatherInfo = json_decode($response, true);
+        // 缓存结果,设置1小时过期
+        $cache->set($cacheKey, serialize($WeatherInfo), 3600);
         if($WeatherInfo){
             return Result::success($WeatherInfo);
         }else{

+ 52 - 0
app/JsonRpc/WebsiteService.php

@@ -2396,4 +2396,56 @@ class WebsiteService implements WebsiteServiceInterface
             return Result::error("更新失败", 0);
         }
     }
+
+    //获取底部导航内容详情
+    public function getFooterContentInfo(array $data): array
+    {
+        $where = [
+            "id" => $data['content_id']
+        ];
+        $result = FooterContent::where($where)->first();
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error("没有数据");
+        }
+    }
+    //获取底部导航内容列表
+    public function getFooterContentList(array $data): array
+    {
+        $where = [
+            "fcat_id" => $data['fcat_id'],
+        ];
+        switch (intval($data['type'])) {
+            case 0:
+                $result = FooterContent::where($where)->first();
+                break;
+            case 1:
+                $result = FooterContent::where($where)->get();
+                break;
+        }
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error("没有数据");
+        }
+    }
+
+    /**
+     * 获取底部导航列表
+     * @param array $data
+     * @return array
+     */
+    public function getFooterCategoryList(array $data): array
+    {
+        $where = [
+            "website_id" => $data['website_id']
+        ];
+        $result = FooterCategory::where($where)->get();
+        if ($result) {
+            return Result::success($result);
+        } else {
+            return Result::error("没有数据");
+        }
+    }
 }

+ 5 - 0
app/JsonRpc/WebsiteServiceInterface.php

@@ -138,4 +138,9 @@ interface WebsiteServiceInterface
     public function getWebsiteHead(array $data): array;
     
     public function getWebsiteRoute(array $data): array;
+
+    public function getFooterCategoryList(array $data): array;
+    public function getFooterContentList(array $data): array;
+    public function getFooterContentInfo(array $data): array;
+
 }

File diff suppressed because it is too large
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-14479
+19507

Some files were not shown because too many files changed in this diff