作者 lyh

GX生成白帽报表脚本

@@ -9,7 +9,9 @@ @@ -9,7 +9,9 @@
9 9
10 namespace App\Console\Commands\Geo; 10 namespace App\Console\Commands\Geo;
11 11
  12 +use App\Models\Geo\GeoPlatform;
12 use App\Models\Geo\GeoQuestion; 13 use App\Models\Geo\GeoQuestion;
  14 +use App\Services\Geo\GeoService;
13 use Illuminate\Console\Command; 15 use Illuminate\Console\Command;
14 use Illuminate\Support\Facades\Redis; 16 use Illuminate\Support\Facades\Redis;
15 17
@@ -30,8 +32,30 @@ class GeoQuestionResult extends Command @@ -30,8 +32,30 @@ class GeoQuestionResult extends Command
30 protected $description = 'geo设置请求获取结果'; 32 protected $description = 'geo设置请求获取结果';
31 33
32 public function handle(){ 34 public function handle(){
33 - $task_id = $this->getTaskId();  
34 - dd($task_id); 35 + while (true){
  36 + $task_id = $this->getTaskId();
  37 + $questionModel = new GeoQuestion();//问题
  38 + $info = $questionModel->read(['id'=>$task_id]);
  39 + $questionArr = $info['question'];
  40 + if(empty($questionArr)){
  41 + echo date('Y-m-d H:i:s').'当前任务不存在问题。'.PHP_EOL;
  42 + $questionModel->edit(['status'=>2],['id'=>$task_id]);
  43 + }
  44 + //获取平台信息
  45 + $platformModel = new GeoPlatform();//平台
  46 + $platformArr = $platformModel->selectField(['status'=>$platformModel::STATUS_ON],'en_name');
  47 + if(empty($platformArr)){
  48 + echo date('Y-m-d H:i:s').'请求平台为空。'.PHP_EOL;
  49 + continue;
  50 + }
  51 + $geoService = new GeoService();
  52 + foreach ($questionArr as $q_item){
  53 + foreach ($platformArr as $p_item){
  54 + dd($q_item,$p_item);
  55 + $geoService->setWebSearchChatAction($q_item,$p_item);
  56 + }
  57 + }
  58 + }
35 } 59 }
36 60
37 /** 61 /**
@@ -35,7 +35,7 @@ class GeoPlatform extends Base @@ -35,7 +35,7 @@ class GeoPlatform extends Base
35 public function getList(){ 35 public function getList(){
36 $data = Cache::get('geo_platform'); 36 $data = Cache::get('geo_platform');
37 if(empty($data)){ 37 if(empty($data)){
38 - $data = $this->list(['status'=>$this::STATUS_ON],'id',['name','icon','sort'],'desc'); 38 + $data = $this->list(['status'=>$this::STATUS_ON],'id',['name','en_name','icon','sort'],'desc');
39 Cache::put('geo_platform',$data,'12 * 3600'); 39 Cache::put('geo_platform',$data,'12 * 3600');
40 } 40 }
41 return $data; 41 return $data;
@@ -21,7 +21,7 @@ class GeoService @@ -21,7 +21,7 @@ class GeoService
21 * @method :post 21 * @method :post
22 * @time :2025/7/3 14:26 22 * @time :2025/7/3 14:26
23 */ 23 */
24 - public function webSearchChatAction($content,$platform){ 24 + public function setWebSearchChatAction($content,$platform){
25 $route = 'v1/websearch_chat'; 25 $route = 'v1/websearch_chat';
26 $url = $this->api_url.$route; 26 $url = $this->api_url.$route;
27 $header = [ 27 $header = [