作者 李宇航

合并分支 'lyh-server' 到 'master'

gx



查看合并请求 !1644
... ... @@ -80,6 +80,25 @@ class GoogleKeywordInsightController extends BaseController
}
/**
* @remark :保存一条关键字数据
* @name :getKeywordInsightDetail
* @author :lyh
* @method :post
* @time :2025/4/1 11:23
*/
public function getKeywordInsightDetail(GoogleKeywordInsightLogic $logic){
$this->request->validate([
'keyword' => 'required'
],[
'keyword.required' => '关键词不能为空',
]);
$result = $logic->getGoogleInsightDetail();
$detailModel = new GoogleKeywordInsightDetail();
$data = $detailModel->read(['id'=>$result['id']]);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :查看当前数据是否存在数组中
* @name :getSearchDetail
* @author :lyh
... ...
... ... @@ -55,4 +55,29 @@ class GoogleKeywordInsightLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :保存一条数据
* @name :saveGoogleKeywordInsight
* @author :lyh
* @method :post
* @time :2025/3/25 14:36
*/
public function getGoogleInsightDetail(){
$this->service = new GoogleSearchService();
$data = $this->service->requestUrl($this->param['keyword']);
if(!empty($data)){
DB::beginTransaction();
//保存数据库
try {
$detailModel = new GoogleKeywordInsightDetail();
$id = $detailModel->saveInsightDetailOne($this->user['project_id'],$this->param['keyword'],$data[0]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
}
return $this->success(['id'=>$id ?? 0]);
}
}
... ...
... ... @@ -43,4 +43,28 @@ class GoogleKeywordInsightDetail extends Base
}
return $this->insertAll($saveData);
}
/**
* @remark :保存一条数据
* @name :saveInsightDetailOne
* @author :lyh
* @method :post
* @time :2025/4/1 11:32
*/
public function saveInsightDetailOne($project_id,$keyword,$data){
$transData = Translate::tran($data['text'], 'zh');
$saveData = [
'search'=>$keyword,
'text'=>$data['text'],
'zh_text'=>$transData ?? $data['text'],
'project_id'=>$project_id,
'volume'=>$data['volume'],
'competition_level'=>$data['competition_level'],
'competition_index'=>$data['competition_index'],
'low_bid'=>$data['low_bid'],
'high_bid'=>$data['high_bid'],
'trend'=>$data['trend'],
];
return $this->addReturnId($saveData);
}
}
... ...
... ... @@ -700,6 +700,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('google_keyword_insight')->group(function () {
Route::any('/getKeywordInsight', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getKeywordInsight'])->name('google_keyword_insight_getKeywordInsight');
Route::any('/getOptimizeList', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getOptimizeList'])->name('google_keyword_insight_getOptimizeList');
Route::any('/getKeywordInsightDetail', [\App\Http\Controllers\Bside\GoogleKeyword\GoogleKeywordInsightController::class, 'getKeywordInsightDetail'])->name('google_keyword_insight_getKeywordInsightDetail');
});
//google搜索数据
Route::prefix('google_search')->group(function () {
... ...