作者 李宇航

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

gx导入项目脚本



查看合并请求 !2113
@@ -227,7 +227,8 @@ class SyncProject extends Command @@ -227,7 +227,8 @@ class SyncProject extends Command
227 'version'=>$version 227 'version'=>$version
228 ], 228 ],
229 'deploy_build' => [ 229 'deploy_build' => [
230 - 'login_mobile'=>$param['principal_mobile'] 230 + 'login_mobile'=>$param['principal_mobile'],
  231 + 'ads_price'=>$param['ads_price'] ?? 0
231 ], 232 ],
232 'deploy_optimize' => [ 233 'deploy_optimize' => [
233 // 'api_no' => 0 234 // 'api_no' => 0
@@ -3,13 +3,17 @@ @@ -3,13 +3,17 @@
3 namespace App\Http\Controllers\Bside\Product; 3 namespace App\Http\Controllers\Bside\Product;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Common;
  7 +use App\Helper\Gpt;
6 use App\Http\Controllers\Bside\BaseController; 8 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Product\KeywordLogic; 9 use App\Http\Logic\Bside\Product\KeywordLogic;
8 use App\Http\Requests\Bside\Product\KeywordRequest; 10 use App\Http\Requests\Bside\Product\KeywordRequest;
  11 +use App\Models\Ai\AiCommand;
9 use App\Models\Product\Keyword; 12 use App\Models\Product\Keyword;
10 use App\Models\Product\KeywordPage; 13 use App\Models\Product\KeywordPage;
11 use App\Models\Product\KeywordRelated; 14 use App\Models\Product\KeywordRelated;
12 use App\Models\Product\Product; 15 use App\Models\Product\Product;
  16 +use App\Models\Project\AggregateKeywordComment;
13 use App\Rules\Ids; 17 use App\Rules\Ids;
14 use Illuminate\Http\Request; 18 use Illuminate\Http\Request;
15 19
@@ -312,4 +316,23 @@ class KeywordController extends BaseController @@ -312,4 +316,23 @@ class KeywordController extends BaseController
312 $logic->delAllRelated($this->param['keyword_id']); 316 $logic->delAllRelated($this->param['keyword_id']);
313 $this->response('success'); 317 $this->response('success');
314 } 318 }
  319 +
  320 + /**
  321 + * @remark :生成评论
  322 + * @name :sendComment
  323 + * @author :lyh
  324 + * @method :post
  325 + * @time :2025/6/9 11:10
  326 + */
  327 + public function sendComment(KeywordLogic $logic){
  328 + $this->request->validate([
  329 + 'count'=>'required|max:10',
  330 + ],[
  331 + 'count.required' => '生成条数不能为空',
  332 + 'count.max'=>'count最大10',
  333 + ]);
  334 + $data = $logic->sendComment();
  335 + $this->response('success',Code::SUCCESS,$data);
  336 + }
  337 +
315 } 338 }
@@ -5,12 +5,15 @@ namespace App\Http\Logic\Bside\Product; @@ -5,12 +5,15 @@ namespace App\Http\Logic\Bside\Product;
5 use App\Exceptions\BsideGlobalException; 5 use App\Exceptions\BsideGlobalException;
6 use App\Helper\Arr; 6 use App\Helper\Arr;
7 use App\Helper\Common; 7 use App\Helper\Common;
  8 +use App\Helper\Gpt;
8 use App\Http\Logic\Bside\BaseLogic; 9 use App\Http\Logic\Bside\BaseLogic;
  10 +use App\Models\Ai\AiCommand;
9 use App\Models\Com\NoticeLog; 11 use App\Models\Com\NoticeLog;
10 use App\Models\News\News; 12 use App\Models\News\News;
11 use App\Models\Product\Keyword; 13 use App\Models\Product\Keyword;
12 use App\Models\Product\KeywordRelated; 14 use App\Models\Product\KeywordRelated;
13 use App\Models\Product\Product; 15 use App\Models\Product\Product;
  16 +use App\Models\Project\AggregateKeywordComment;
14 use App\Models\RouteMap\RouteMap; 17 use App\Models\RouteMap\RouteMap;
15 use App\Models\User\User; 18 use App\Models\User\User;
16 use Illuminate\Support\Facades\DB; 19 use Illuminate\Support\Facades\DB;
@@ -345,4 +348,46 @@ class KeywordLogic extends BaseLogic @@ -345,4 +348,46 @@ class KeywordLogic extends BaseLogic
345 return $this->success(); 348 return $this->success();
346 } 349 }
347 350
  351 + /**
  352 + * @remark :保存数据
  353 + * @name :sendComment
  354 + * @author :lyh
  355 + * @method :post
  356 + * @time :2025/6/9 11:19
  357 + */
  358 + public function sendComment()
  359 + {
  360 + $aiCommonModel = new AiCommand();
  361 + $info = $aiCommonModel->read(['key' => 'tag_comment','project_id'=>$this->user['project_id']]);
  362 + if($info === false){
  363 + $info = $aiCommonModel->read(['key' => 'tag_comment']);
  364 + $info['ai'] = str_replace('50', $this->param['count'], $info['ai']);
  365 + }
  366 + $text = Gpt::instance()->openai_chat_qqs($info['ai']);
  367 + $text = Common::deal_keywords($text);
  368 + preg_match_all('/\{[^{}]*\}/', $text, $matches);
  369 + $data = [];
  370 + if (!empty($text)) {
  371 + foreach ($matches[0] as $item) {
  372 + $item = str_replace("'", '"', $item);
  373 + // 解码成 PHP 关联数组
  374 + $item = json_decode($item, true);
  375 + if (!isset($item['name']) || !isset($item['comment'])) {
  376 + continue;
  377 + }
  378 + $data[] = [
  379 + 'nickname' => $item['name'],
  380 + 'text' => $item['comment'],
  381 + 'project_id' => $this->user['project_id'],
  382 + 'type' => 1,
  383 + 'uid' => 0,
  384 + 'created_at' => date('Y-m-d H:i:s'),
  385 + 'updated_at' => date('Y-m-d H:i:s')
  386 + ];
  387 + }
  388 + }
  389 + $keywordCommonModel = new AggregateKeywordComment();
  390 + $keywordCommonModel->insertAll($data);
  391 + return $this->success($data);
  392 + }
348 } 393 }
@@ -327,6 +327,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -327,6 +327,7 @@ Route::middleware(['bloginauth'])->group(function () {
327 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo'); 327 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
328 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); 328 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
329 Route::any('keyword/delRelatedProductId', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delRelatedProductId'])->name('product_keyword_delRelatedProductId'); 329 Route::any('keyword/delRelatedProductId', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delRelatedProductId'])->name('product_keyword_delRelatedProductId');
  330 + Route::any('keyword/sendComment', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'sendComment'])->name('product_keyword_sendComment');
330 //产品参数 331 //产品参数
331 Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr'); 332 Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr');
332 Route::get('attr/info', [\App\Http\Controllers\Bside\Product\AttrController::class, 'info'])->name('product_attr_info'); 333 Route::get('attr/info', [\App\Http\Controllers\Bside\Product\AttrController::class, 'info'])->name('product_attr_info');