正在显示
3 个修改的文件
包含
17 行增加
和
2 行删除
| @@ -9,7 +9,9 @@ | @@ -9,7 +9,9 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Http\Controllers\Bside\GoogleKeywordInsight; | 10 | namespace App\Http\Controllers\Bside\GoogleKeywordInsight; |
| 11 | 11 | ||
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | +use App\Http\Logic\Bside\GoogleKeywordInsight\GoogleKeywordInsightLogic; | ||
| 13 | 15 | ||
| 14 | /** | 16 | /** |
| 15 | * @remark :谷歌洞察数据 | 17 | * @remark :谷歌洞察数据 |
| @@ -27,11 +29,13 @@ class GoogleKeywordInsightController extends BaseController | @@ -27,11 +29,13 @@ class GoogleKeywordInsightController extends BaseController | ||
| 27 | * @method :post | 29 | * @method :post |
| 28 | * @time :2025/3/25 14:30 | 30 | * @time :2025/3/25 14:30 |
| 29 | */ | 31 | */ |
| 30 | - public function saveKeywordInsight(){ | 32 | + public function getKeywordInsight(GoogleKeywordInsightLogic $logic){ |
| 31 | $this->request->validate([ | 33 | $this->request->validate([ |
| 32 | 'keyword' => 'required' | 34 | 'keyword' => 'required' |
| 33 | ],[ | 35 | ],[ |
| 34 | 'keyword.required' => '关键词不能为空', | 36 | 'keyword.required' => '关键词不能为空', |
| 35 | ]); | 37 | ]); |
| 38 | + $data = $logic->getGoogleInsight(); | ||
| 39 | + $this->response('success',Code::SUCCESS,$data); | ||
| 36 | } | 40 | } |
| 37 | } | 41 | } |
| @@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Http\Logic\Bside\GoogleKeywordInsight; | 10 | namespace App\Http\Logic\Bside\GoogleKeywordInsight; |
| 11 | 11 | ||
| 12 | +use App\Helper\Translate; | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 13 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | use App\Models\GoogleKeywordInsight\GoogleKeywordInsight; | 14 | use App\Models\GoogleKeywordInsight\GoogleKeywordInsight; |
| 14 | use App\Services\GoogleKeywordInsightService; | 15 | use App\Services\GoogleKeywordInsightService; |
| @@ -32,7 +33,7 @@ class GoogleKeywordInsightLogic extends BaseLogic | @@ -32,7 +33,7 @@ class GoogleKeywordInsightLogic extends BaseLogic | ||
| 32 | * @time :2025/3/25 14:36 | 33 | * @time :2025/3/25 14:36 |
| 33 | */ | 34 | */ |
| 34 | public function getGoogleInsight(){ | 35 | public function getGoogleInsight(){ |
| 35 | - $data = $this->model->read(['project_id'=>$this->user['project_id'],'search'=>$this->param['keyword']]); | 36 | + $data = $this->model->read(['search'=>$this->param['keyword']]); |
| 36 | if($data === false){ | 37 | if($data === false){ |
| 37 | $this->service = new GoogleKeywordInsightService(); | 38 | $this->service = new GoogleKeywordInsightService(); |
| 38 | $data = $this->service->requestUrl($this->param['keyword']); | 39 | $data = $this->service->requestUrl($this->param['keyword']); |
| @@ -71,9 +72,14 @@ class GoogleKeywordInsightLogic extends BaseLogic | @@ -71,9 +72,14 @@ class GoogleKeywordInsightLogic extends BaseLogic | ||
| 71 | public function saveInsightDetail($keyword,$data){ | 72 | public function saveInsightDetail($keyword,$data){ |
| 72 | $saveData = []; | 73 | $saveData = []; |
| 73 | foreach ($data as $val){ | 74 | foreach ($data as $val){ |
| 75 | + $zh_text = Translate::tran($val['text'], 'zh'); | ||
| 76 | + if(empty($zh_text)){ | ||
| 77 | + $zh_text = $val['text']; | ||
| 78 | + } | ||
| 74 | $saveData[] = [ | 79 | $saveData[] = [ |
| 75 | 'search'=>$keyword, | 80 | 'search'=>$keyword, |
| 76 | 'text'=>$val['text'], | 81 | 'text'=>$val['text'], |
| 82 | + 'zh_text'=>$zh_text, | ||
| 77 | 'project_id'=>$this->user['project_id'], | 83 | 'project_id'=>$this->user['project_id'], |
| 78 | 'volume'=>$val['volume'], | 84 | 'volume'=>$val['volume'], |
| 79 | 'competition_level'=>$val['competition_level'], | 85 | 'competition_level'=>$val['competition_level'], |
| @@ -695,6 +695,11 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -695,6 +695,11 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 695 | Route::any('/getInfo', [\App\Http\Controllers\Bside\SeoSetting\DomainSettingController::class, 'getInfo'])->name('domain_setting_getInfo'); | 695 | Route::any('/getInfo', [\App\Http\Controllers\Bside\SeoSetting\DomainSettingController::class, 'getInfo'])->name('domain_setting_getInfo'); |
| 696 | Route::any('/save', [\App\Http\Controllers\Bside\SeoSetting\DomainSettingController::class, 'save'])->name('domain_setting_save'); | 696 | Route::any('/save', [\App\Http\Controllers\Bside\SeoSetting\DomainSettingController::class, 'save'])->name('domain_setting_save'); |
| 697 | }); | 697 | }); |
| 698 | + | ||
| 699 | + //google数据洞察 | ||
| 700 | + Route::prefix('google_keyword_insight')->group(function () { | ||
| 701 | + Route::any('/getKeywordInsight', [\App\Http\Controllers\Bside\GoogleKeywordInsight\GoogleKeywordInsightController::class, 'getKeywordInsight'])->name('google_keyword_insight_getKeywordInsight'); | ||
| 702 | + }); | ||
| 698 | }); | 703 | }); |
| 699 | //无需登录验证的路由组 | 704 | //无需登录验证的路由组 |
| 700 | Route::group([], function () { | 705 | Route::group([], function () { |
-
请 注册 或 登录 后发表评论