作者 lyh

gx生成评论

@@ -73,18 +73,25 @@ class InitKeywordComment extends Command @@ -73,18 +73,25 @@ class InitKeywordComment extends Command
73 $item = str_replace("'", '"', $item); 73 $item = str_replace("'", '"', $item);
74 // 解码成 PHP 关联数组 74 // 解码成 PHP 关联数组
75 $item = json_decode($item, true); 75 $item = json_decode($item, true);
76 - var_dump($item['name']);  
77 -// $data[] = [  
78 -// 'nickname'=>$item['name'],  
79 -// 'text'=>$item['comment'],  
80 -// 'project_id'=>$project_id,  
81 -// 'type'=>1,  
82 -// 'uid'=>0,  
83 -// ]; 76 + if(!isset($item) || !isset($item)){
  77 + continue;
  78 + }
  79 + $data[] = [
  80 + 'nickname'=>$item['name'],
  81 + 'text'=>$item['comment'],
  82 + 'project_id'=>$project_id,
  83 + 'type'=>1,
  84 + 'uid'=>0,
  85 + 'created_at'=>date('Y-m-d H:i:s'),
  86 + 'updated_at'=>date('Y-m-d H:i:s')
  87 + ];
84 } 88 }
85 - die();  
86 -// $keywordCommonModel = new AggregateKeywordComment();  
87 -// $keywordCommonModel->insertAll($data); 89 + $keywordCommonModel = new AggregateKeywordComment();
  90 + $keywordCommonModel->insertAll($data);
  91 + }
  92 + $count = $keywordCommonModel->counts(['project_id'=>$project_id]);
  93 + if($count < 100){
  94 + $this->_action($project_id);
88 } 95 }
89 return true; 96 return true;
90 } 97 }