GoogleSearchController.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @remark :
* @name :GoogleSearchController.php
* @author :lyh
* @method :post
* @time :2025/3/27 13:53
*/
namespace App\Http\Controllers\Bside\GoogleKeyword;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\NoticeLog;
use App\Models\GoogleSearch\GoogleSearch;
use App\Models\GoogleSearch\GoogleSearchDetail;
use App\Services\GoogleSearchService;
class GoogleSearchController extends BaseController
{
/**
* @remark :google搜索数据
* @name :searchList
* @author :lyh
* @method :post
* @time :2025/3/27 13:59
*/
public function getSearchList(){
$this->request->validate([
'search' => 'required'
],[
'search.required' => '搜索类型不能为空',
]);
//查询数据库查看是否有数据
$googleSearchModel = new GoogleSearch();
$searchInfo = $googleSearchModel->read(['type'=>$this->map['search'],'project_id'=>$this->user['project_id'],'date'=>['<=',date('Y-m-d', strtotime('-7 days'))]],['id']);
if($searchInfo === false){
//获取当前项目域名
$domain = parse_url($this->user['domain'], PHP_URL_HOST);
$data = NoticeLog::createLog(NoticeLog::DELETE_CUSTOM_CATEGORY, ['project_id' => $this->user['project_id'],'domain'=>$domain,'type'=>$this->param['search']]);
$this->response('数据生成中...',Code::SUCCESS,$data);
}
//查询详情数据
$searchDetailModel = new GoogleSearchDetail();
$this->map['project_id']= $this->user['project_id'];
$data = $searchDetailModel->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$data);
}
}