GoogleSearchController.php 1.5 KB
<?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\Helper\Country;
use App\Helper\Translate;
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([
            'type' => 'required'
        ],[
            'type.required' => '搜索类型不能为空',
        ]);
        //查询详情数据
        $searchDetailModel = new GoogleSearchDetail();
        $this->map['project_id']= $this->user['project_id'];
        $data = $searchDetailModel->lists($this->map,$this->page,$this->row);
        if($this->param['type'] == 'country'){
            $country = [];
            foreach ($data as $val){
                $country[] = Country::getCountryNameByAlpha3($val['keys']);
            }
            $zh_country = Translate::tran($country, 'zh');
            foreach ($data as $key => $val){
                $val['zh_country'] = $zh_country[$key];
                $data[$key] = $val;
            }
        }
        $this->response('success',Code::SUCCESS,$data);
    }
}