作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiBlogTask.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/2/14 11:14
  8 + */
  9 +
  10 +namespace App\Console\Commands\AiBlog;
  11 +
  12 +use App\Models\Ai\AiBlog;
  13 +use App\Models\Ai\AiBlogAuthor;
  14 +use App\Models\Ai\AiBlogList;
  15 +use App\Models\Project\ProjectAiSetting;
  16 +use App\Models\RouteMap\RouteMap;
  17 +use App\Services\AiBlogService;
  18 +use App\Services\ProjectServer;
  19 +use Illuminate\Console\Command;
  20 +use App\Models\Project\AiBlogTask as AiBlogTaskModel;
  21 +use Illuminate\Support\Facades\Cache;
  22 +use Illuminate\Support\Facades\DB;
  23 +use function Symfony\Component\String\s;
  24 +
  25 +class AiBlogListTask extends Command
  26 +{
  27 + /**
  28 + * The name and signature of the console command.
  29 + *
  30 + * @var string
  31 + */
  32 + protected $signature = 'save_ai_blog_list {project_id}';
  33 +
  34 + /**
  35 + * The console command description.
  36 + *
  37 + * @var string
  38 + */
  39 + protected $description = '生成blog列表';
  40 +
  41 + public function handle(){
  42 + $project_id = $this->argument('project_id');
  43 + ProjectServer::useProject($project_id);
  44 + $projectAiSettingModel = new ProjectAiSetting();
  45 + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]);
  46 + $this->updateBlogList($aiSettingInfo);
  47 + DB::disconnect('custom_mysql');
  48 + return true;
  49 + }
  50 +
  51 + /**
  52 + * @remark :更新列表页数据
  53 + * @name :updateBlogList
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2025/3/5 11:07
  57 + */
  58 + public function updateBlogList($aiSettingInfo){
  59 + $aiBlogService = new AiBlogService();
  60 + $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
  61 + $aiBlogService->key = $aiSettingInfo['key'];
  62 + $page = 1;
  63 + $saveData = [];
  64 + $result = $aiBlogService->getAiBlogList($page,15);
  65 + if(!isset($result['status']) && $result['status'] != 200){
  66 + return true;
  67 + }
  68 + $total_page = $result['data']['total_page'];
  69 + //组装数据保存
  70 + $saveData[] = [
  71 + 'route'=>$page,
  72 + 'text'=>$result['data']['section'],
  73 + ];
  74 + while ($total_page > $page){
  75 + $page++;
  76 + $result = $aiBlogService->getAiBlogList($page,15);
  77 + if(isset($result['status']) && $result['status'] == 200){
  78 + $saveData[] = [
  79 + 'route'=>$page,
  80 + 'text'=>$result['data']['section'],
  81 + ];
  82 + }
  83 + }
  84 + $aiBlogListModel = new AiBlogList();
  85 + if(!empty($saveData)){
  86 + //写一条路由信息
  87 + $aiBlogListModel->truncate();
  88 + $aiBlogListModel->insertAll($saveData);
  89 + }
  90 + return true;
  91 + }
  92 +}
@@ -387,7 +387,7 @@ class OptimizeController extends BaseController @@ -387,7 +387,7 @@ class OptimizeController extends BaseController
387 } 387 }
388 $url = $domain.'api/update_robots/?project_id='.$this->param['project_id']; 388 $url = $domain.'api/update_robots/?project_id='.$this->param['project_id'];
389 $res = curlGet($url); 389 $res = curlGet($url);
390 - if(empty($res) || $res['status'] != 200){ 390 + if(empty($res) || !isset($res['status']) || $res['status'] != 200){
391 $this->response('生成robots失败,请联系开发人员',Code::SYSTEM_ERROR,['url'=>$url]); 391 $this->response('生成robots失败,请联系开发人员',Code::SYSTEM_ERROR,['url'=>$url]);
392 } 392 }
393 $this->response('success',Code::SUCCESS,['url'=>$domain.'robots.txt']); 393 $this->response('success',Code::SUCCESS,['url'=>$domain.'robots.txt']);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiVideoController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/3/5 11:00
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Ai;
  11 +
  12 +use App\Http\Controllers\Bside\BaseController;
  13 +
  14 +class AiVideoController extends BaseController
  15 +{
  16 +
  17 +}
@@ -6,6 +6,7 @@ use App\Helper\Translate; @@ -6,6 +6,7 @@ use App\Helper\Translate;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\Ai\AiBlog; 7 use App\Models\Ai\AiBlog;
8 use App\Models\Ai\AiBlogAuthor; 8 use App\Models\Ai\AiBlogAuthor;
  9 +use App\Models\Ai\AiBlogList;
9 use App\Models\Project\AiBlogTask; 10 use App\Models\Project\AiBlogTask;
10 use App\Models\Project\Project; 11 use App\Models\Project\Project;
11 use App\Models\Project\ProjectAiSetting; 12 use App\Models\Project\ProjectAiSetting;
@@ -131,10 +132,12 @@ class AiBlogLogic extends BaseLogic @@ -131,10 +132,12 @@ class AiBlogLogic extends BaseLogic
131 RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); 132 RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']);
132 $this->model->del(['id'=>$id]); 133 $this->model->del(['id'=>$id]);
133 } 134 }
  135 + shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &');
134 }catch (\Exception $e){ 136 }catch (\Exception $e){
135 $this->fail('删除失败'); 137 $this->fail('删除失败');
136 } 138 }
137 return $this->success(); 139 return $this->success();
138 } 140 }
139 141
  142 +
140 } 143 }