作者 lyh

gx导入项目脚本

... ... @@ -227,7 +227,8 @@ class SyncProject extends Command
'version'=>$version
],
'deploy_build' => [
'login_mobile'=>$param['principal_mobile']
'login_mobile'=>$param['principal_mobile'],
'ads_price'=>$param['ads_price'] ?? 0
],
'deploy_optimize' => [
// 'api_no' => 0
... ...
... ... @@ -3,13 +3,17 @@
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Helper\Gpt;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\KeywordLogic;
use App\Http\Requests\Bside\Product\KeywordRequest;
use App\Models\Ai\AiCommand;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordPage;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\AggregateKeywordComment;
use App\Rules\Ids;
use Illuminate\Http\Request;
... ... @@ -312,4 +316,23 @@ class KeywordController extends BaseController
$logic->delAllRelated($this->param['keyword_id']);
$this->response('success');
}
/**
* @remark :生成评论
* @name :sendComment
* @author :lyh
* @method :post
* @time :2025/6/9 11:10
*/
public function sendComment(KeywordLogic $logic){
$this->request->validate([
'count'=>'required|max:10',
],[
'count.required' => '生成条数不能为空',
'count.max'=>'count最大10',
]);
$data = $logic->sendComment();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -5,12 +5,15 @@ namespace App\Http\Logic\Bside\Product;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Helper\Gpt;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Ai\AiCommand;
use App\Models\Com\NoticeLog;
use App\Models\News\News;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\AggregateKeywordComment;
use App\Models\RouteMap\RouteMap;
use App\Models\User\User;
use Illuminate\Support\Facades\DB;
... ... @@ -345,4 +348,46 @@ class KeywordLogic extends BaseLogic
return $this->success();
}
/**
* @remark :保存数据
* @name :sendComment
* @author :lyh
* @method :post
* @time :2025/6/9 11:19
*/
public function sendComment()
{
$aiCommonModel = new AiCommand();
$info = $aiCommonModel->read(['key' => 'tag_comment','project_id'=>$this->user['project_id']]);
if($info === false){
$info = $aiCommonModel->read(['key' => 'tag_comment']);
$info['ai'] = str_replace('50', $this->param['count'], $info['ai']);
}
$text = Gpt::instance()->openai_chat_qqs($info['ai']);
$text = Common::deal_keywords($text);
preg_match_all('/\{[^{}]*\}/', $text, $matches);
$data = [];
if (!empty($text)) {
foreach ($matches[0] as $item) {
$item = str_replace("'", '"', $item);
// 解码成 PHP 关联数组
$item = json_decode($item, true);
if (!isset($item['name']) || !isset($item['comment'])) {
continue;
}
$data[] = [
'nickname' => $item['name'],
'text' => $item['comment'],
'project_id' => $this->user['project_id'],
'type' => 1,
'uid' => 0,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
}
}
$keywordCommonModel = new AggregateKeywordComment();
$keywordCommonModel->insertAll($data);
return $this->success($data);
}
}
... ...
... ... @@ -327,6 +327,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
Route::any('keyword/delRelatedProductId', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delRelatedProductId'])->name('product_keyword_delRelatedProductId');
Route::any('keyword/sendComment', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'sendComment'])->name('product_keyword_sendComment');
//产品参数
Route::get('attr', [\App\Http\Controllers\Bside\Product\AttrController::class, 'index'])->name('product_attr');
Route::get('attr/info', [\App\Http\Controllers\Bside\Product\AttrController::class, 'info'])->name('product_attr_info');
... ...