作者 lyh

gx生成评论

@@ -13,6 +13,7 @@ use App\Helper\Common; @@ -13,6 +13,7 @@ use App\Helper\Common;
13 use App\Helper\Gpt; 13 use App\Helper\Gpt;
14 use App\Models\Ai\AiCommand; 14 use App\Models\Ai\AiCommand;
15 use App\Models\Com\NoticeLog; 15 use App\Models\Com\NoticeLog;
  16 +use App\Models\Project\AggregateKeywordCommon;
16 use Illuminate\Console\Command; 17 use Illuminate\Console\Command;
17 18
18 class InitKeywordCommon extends Command 19 class InitKeywordCommon extends Command
@@ -34,7 +35,7 @@ class InitKeywordCommon extends Command @@ -34,7 +35,7 @@ class InitKeywordCommon extends Command
34 35
35 36
36 public function handle(){ 37 public function handle(){
37 - return $this->_action(); 38 + return $this->_action(467);
38 while (true){ 39 while (true){
39 $list = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD_COMMON)->where('status', NoticeLog::STATUS_PENDING)->get(); 40 $list = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD_COMMON)->where('status', NoticeLog::STATUS_PENDING)->get();
40 } 41 }
@@ -48,13 +49,27 @@ class InitKeywordCommon extends Command @@ -48,13 +49,27 @@ class InitKeywordCommon extends Command
48 * @method :post 49 * @method :post
49 * @time :2025/6/3 15:42 50 * @time :2025/6/3 15:42
50 */ 51 */
51 - public function _action(){ 52 + public function _action($project_id){
52 $aiCommonModel = new AiCommand(); 53 $aiCommonModel = new AiCommand();
53 $info = $aiCommonModel->read(['key'=>'tag_comment']); 54 $info = $aiCommonModel->read(['key'=>'tag_comment']);
54 $text = Gpt::instance()->openai_chat_qqs($info['ai']); 55 $text = Gpt::instance()->openai_chat_qqs($info['ai']);
55 $text = Common::deal_keywords($text); 56 $text = Common::deal_keywords($text);
  57 + $text = Common::deal_str($text);
56 $text = preg_match_all('/\{[^{}]*\}/', $text, $matches); 58 $text = preg_match_all('/\{[^{}]*\}/', $text, $matches);
57 - dd($matches[0]);  
58 - return Common::deal_str($text); 59 + if(!empty($text)){
  60 + $data = [];
  61 + foreach ($text as $item){
  62 + $data[] = [
  63 + 'nickname'=>$item['name'],
  64 + 'text'=>$item['comment'],
  65 + 'project_id'=>$project_id,
  66 + 'type'=>1,
  67 + 'uid'=>0,
  68 + ];
  69 + }
  70 + $keywordCommonModel = new AggregateKeywordCommon();
  71 + $keywordCommonModel->insertAll($data);
  72 + }
  73 + return true;
59 } 74 }
60 } 75 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AggregateKeywordCommon.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/6/3 17:42
  8 + */
  9 +
  10 +namespace App\Models\Project;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class AggregateKeywordCommon extends Base
  15 +{
  16 + protected $table = 'gl_aggregate_keyword_common';
  17 +}