|
|
@ -8,6 +8,8 @@ use app\exception\ModelEmptyException; |
|
|
use app\model\Category; |
|
|
use app\model\Category; |
|
|
use app\model\CategorySubContent; |
|
|
use app\model\CategorySubContent; |
|
|
use app\model\SubContent; |
|
|
use app\model\SubContent; |
|
|
|
|
|
use think\facade\Cache; |
|
|
|
|
|
use think\facade\Db; |
|
|
use think\Request; |
|
|
use think\Request; |
|
|
use think\response\Json; |
|
|
use think\response\Json; |
|
|
|
|
|
|
|
|
@ -95,13 +97,75 @@ class SearchController extends BaseController |
|
|
return $this->fetch(config('view.view_search_page_name')); |
|
|
return $this->fetch(config('view.view_search_page_name')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 交易及市场日历(calendar) 相关文章列表
|
|
|
public function searchCalendar(Request $request) :Json |
|
|
public function searchCalendar(Request $request) :Json |
|
|
{ |
|
|
{ |
|
|
$reqParam = $request->param(); |
|
|
$reqParam = $request->param(); |
|
|
$resData = [ |
|
|
$resData = [ |
|
|
'code'=>200, |
|
|
'code'=>200, |
|
|
|
|
|
'msg'=>'ok', |
|
|
'data'=>[], |
|
|
'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); |
|
|
return json($resData); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|