From cac43f4140ddde6e4acd75e55e89c15c94858742 Mon Sep 17 00:00:00 2001 From: xiaodong Date: Wed, 22 Jul 2026 15:40:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E6=98=93=E5=8F=8A=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E6=97=A5=E5=8E=86(calendar)=20=E7=9B=B8=E5=85=B3=E6=96=87?= =?UTF-8?q?=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/frontend/SearchController.php | 64 ++++++++++++++++++++++++ public/themes/hc_original/dongya-web/index.html | 4 +- public/themes/static_new/index.html | 4 +- public/themes/website/1/zh/dongya-web/index.html | 4 +- route/1_zh_frontend.php | 3 +- 5 files changed, 72 insertions(+), 7 deletions(-) diff --git a/app/controller/frontend/SearchController.php b/app/controller/frontend/SearchController.php index 0c1d80e..9124f0d 100644 --- a/app/controller/frontend/SearchController.php +++ b/app/controller/frontend/SearchController.php @@ -8,6 +8,8 @@ use app\exception\ModelEmptyException; use app\model\Category; use app\model\CategorySubContent; use app\model\SubContent; +use think\facade\Cache; +use think\facade\Db; use think\Request; use think\response\Json; @@ -95,13 +97,75 @@ class SearchController extends BaseController return $this->fetch(config('view.view_search_page_name')); } + // 交易及市场日历(calendar) 相关文章列表 public function searchCalendar(Request $request) :Json { $reqParam = $request->param(); $resData = [ 'code'=>200, + 'msg'=>'ok', 'data'=>[], ]; + $reqDate = $reqParam['date'] ?? ''; // 2026-7-16 + if(empty($reqDate)){ + return json($resData); + } + $cacheKey = 'searchCalendar-'.$reqDate; + $cacheTmp = Cache::get($cacheKey); + if(!empty($cacheTmp)){ + $cacheTmp['msg'] = 'ok-cache'; + return json($cacheTmp); + } + + // 将时间转为传入时间的那一天的开始时间和结束时间(时间戳) + $timestamp = strtotime($reqDate); + if ($timestamp === false) { + return json($resData); + } + $start = strtotime(date('Y-m-d', $timestamp) . ' 00:00:00'); + $end = strtotime(date('Y-m-d', $timestamp) . ' 23:59:59'); + // 查询时间段文章列表 + $articleList = Db::table('hc_sub_content') + ->field('id,title,create_time') + ->where('category_id','=',215) // 交易及市场日历(calendar) + ->where('create_time','>=',$start) + ->where('create_time','<=',$end) + ->select(); + + $resData['data'] = $articleList; + Cache::set($cacheKey,$resData,30); + + return json($resData); + } + + // 交易及市场日历(calendar) 相关文章详情 + public function searchOneArticle(Request $request) :Json + { + $reqParam = $request->param(); + $resData = [ + 'code'=>200, + 'msg'=>'ok', + 'data'=>'', + ]; + $reqID = $reqParam['id'] ?? 0; // hc_sub_content.id + if(empty($reqID)){ + return json($resData); + } + $cacheKey = 'searchOneArticle-'.$reqID; + $cacheTmp = Cache::get($cacheKey); + if(!empty($cacheTmp)){ + $cacheTmp['msg'] = 'ok-cache'; + return json($cacheTmp); + } + // 查询时间段文章列表 + $oneArticle = Db::table('hc_sub_content') + ->field('id,title,create_time,content') + ->where('category_id','=',215) // 交易及市场日历(calendar) + ->where('id','=',$reqID) + ->findOrEmpty(); + $resData['data'] = $oneArticle; + Cache::set($cacheKey,$resData,30); + return json($resData); } } diff --git a/public/themes/hc_original/dongya-web/index.html b/public/themes/hc_original/dongya-web/index.html index 39c2933..9c6f2f1 100644 --- a/public/themes/hc_original/dongya-web/index.html +++ b/public/themes/hc_original/dongya-web/index.html @@ -497,7 +497,7 @@ function timeclick(e) { $("#date-show").html(e); $(".event_ul").empty(); - $.getJSON("/calendar/date-article-list", { date: e }, function (result) { + $.getJSON("/calendar-article-list", { date: e }, function (result) { for (var i = 0; i < result.data.length; i++) { $(".event_ul").append('
  • ' + result.data[i].title + '
  • '); } @@ -516,7 +516,7 @@ }) $(".event_ul").on("click", "li", function () { - $.getJSON("/calendar/article-detail", { id: $(this).data("id") }, function (result) { + $.getJSON("/calendar-article-list", { id: $(this).data("id") }, function (result) { $(".apprais").html(result.data.title); $(".apprais_cont").html(result.data.content); $(".calendar_pop").show(); diff --git a/public/themes/static_new/index.html b/public/themes/static_new/index.html index b05bb0d..e52f298 100644 --- a/public/themes/static_new/index.html +++ b/public/themes/static_new/index.html @@ -973,7 +973,7 @@ function timeclick(e) { $("#date-show").html(e); $(".event_ul").empty(); - $.getJSON("/calendar/date-article-list", { date: e }, function (result) { + $.getJSON("/calendar-article-list", { date: e }, function (result) { for (var i = 0; i < result.data.length; i++) { $(".event_ul").append('
  • ' + result.data[i].title + '
  • '); } @@ -992,7 +992,7 @@ }) $(".event_ul").on("click", "li", function () { - $.getJSON("/calendar/article-detail", { id: $(this).data("id") }, function (result) { + $.getJSON("/calendar-article-list", { id: $(this).data("id") }, function (result) { $(".apprais").html(result.data.title); $(".apprais_cont").html(result.data.content); $(".calendar_pop").show(); diff --git a/public/themes/website/1/zh/dongya-web/index.html b/public/themes/website/1/zh/dongya-web/index.html index 39c2933..c6bac94 100644 --- a/public/themes/website/1/zh/dongya-web/index.html +++ b/public/themes/website/1/zh/dongya-web/index.html @@ -497,7 +497,7 @@ function timeclick(e) { $("#date-show").html(e); $(".event_ul").empty(); - $.getJSON("/calendar/date-article-list", { date: e }, function (result) { + $.getJSON("/calendar-article-list", { date: e }, function (result) { for (var i = 0; i < result.data.length; i++) { $(".event_ul").append('
  • ' + result.data[i].title + '
  • '); } @@ -516,7 +516,7 @@ }) $(".event_ul").on("click", "li", function () { - $.getJSON("/calendar/article-detail", { id: $(this).data("id") }, function (result) { + $.getJSON("/calendar-article-detail", { id: $(this).data("id") }, function (result) { $(".apprais").html(result.data.title); $(".apprais_cont").html(result.data.content); $(".calendar_pop").show(); diff --git a/route/1_zh_frontend.php b/route/1_zh_frontend.php index b0245fa..425b222 100644 --- a/route/1_zh_frontend.php +++ b/route/1_zh_frontend.php @@ -318,7 +318,8 @@ Route::get('/tagList/:id', 'List/tag')->name('List/tag') Route::get('/search', 'Search/index'); // 交易及市场日历(calendar) -Route::get('/calendar/article-detail', 'Search/searchCalendar'); +Route::get('/calendar-article-list', 'Search/searchCalendar'); +Route::get('/calendar-article-detail', 'Search/searchOneArticle');