作者 lyh

gx

... ... @@ -9,7 +9,9 @@
namespace App\Http\Controllers\Bside\GoogleKeywordInsight;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\GoogleKeywordInsight\GoogleKeywordInsightLogic;
/**
* @remark :谷歌洞察数据
... ... @@ -27,11 +29,13 @@ class GoogleKeywordInsightController extends BaseController
* @method :post
* @time :2025/3/25 14:30
*/
public function saveKeywordInsight(){
public function getKeywordInsight(GoogleKeywordInsightLogic $logic){
$this->request->validate([
'keyword' => 'required'
],[
'keyword.required' => '关键词不能为空',
]);
$data = $logic->getGoogleInsight();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Http\Logic\Bside\GoogleKeywordInsight;
use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\GoogleKeywordInsight\GoogleKeywordInsight;
use App\Services\GoogleKeywordInsightService;
... ... @@ -32,7 +33,7 @@ class GoogleKeywordInsightLogic extends BaseLogic
* @time :2025/3/25 14:36
*/
public function getGoogleInsight(){
$data = $this->model->read(['project_id'=>$this->user['project_id'],'search'=>$this->param['keyword']]);
$data = $this->model->read(['search'=>$this->param['keyword']]);
if($data === false){
$this->service = new GoogleKeywordInsightService();
$data = $this->service->requestUrl($this->param['keyword']);
... ... @@ -71,9 +72,14 @@ class GoogleKeywordInsightLogic extends BaseLogic
public function saveInsightDetail($keyword,$data){
$saveData = [];
foreach ($data as $val){
$zh_text = Translate::tran($val['text'], 'zh');
if(empty($zh_text)){
$zh_text = $val['text'];
}
$saveData[] = [
'search'=>$keyword,
'text'=>$val['text'],
'zh_text'=>$zh_text,
'project_id'=>$this->user['project_id'],
'volume'=>$val['volume'],
'competition_level'=>$val['competition_level'],
... ...
... ... @@ -695,6 +695,11 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/getInfo', [\App\Http\Controllers\Bside\SeoSetting\DomainSettingController::class, 'getInfo'])->name('domain_setting_getInfo');
Route::any('/save', [\App\Http\Controllers\Bside\SeoSetting\DomainSettingController::class, 'save'])->name('domain_setting_save');
});
//google数据洞察
Route::prefix('google_keyword_insight')->group(function () {
Route::any('/getKeywordInsight', [\App\Http\Controllers\Bside\GoogleKeywordInsight\GoogleKeywordInsightController::class, 'getKeywordInsight'])->name('google_keyword_insight_getKeywordInsight');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...