|
...
|
...
|
@@ -9,10 +9,16 @@ |
|
|
|
|
|
|
|
namespace App\Console\Commands\Ai;
|
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Models\Ai\AiBlogAuthor;
|
|
|
|
use App\Models\Ai\AiVideo;
|
|
|
|
use App\Models\Ai\AiVideoList;
|
|
|
|
use App\Models\Com\Notify;
|
|
|
|
use App\Models\Devops\ServerConfig;
|
|
|
|
use App\Models\Devops\ServersIp;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Project\AiVideoTask as AiVideoTaskModel;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Services\AiBlogService;
|
|
|
|
use App\Services\AiVideoService;
|
|
...
|
...
|
@@ -33,14 +39,12 @@ class AiVideoTask extends Command |
|
|
|
|
|
|
|
public $updateProject = [];//需更新的列表
|
|
|
|
public $routes = [];//需要更新的路由
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '查询ai_video是否已经生成';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
* @throws \Exception
|
|
...
|
...
|
@@ -72,7 +76,7 @@ class AiVideoTask extends Command |
|
|
|
$this->updateProject = [];
|
|
|
|
}
|
|
|
|
if(!empty($this->routes)){
|
|
|
|
$this->updateRoutes($this->routes);
|
|
|
|
// $this->updateRoutes($this->routes);
|
|
|
|
$this->routes = [];
|
|
|
|
}
|
|
|
|
$aiVideoTaskModel = new AiVideoTaskModel();
|
|
...
|
...
|
@@ -259,6 +263,7 @@ class AiVideoTask extends Command |
|
|
|
$aiVideoListModel = new AiVideoList();
|
|
|
|
if(!empty($saveData)){
|
|
|
|
//写一条路由信息
|
|
|
|
RouteMap::setRoute('top-video',RouteMap::SOURCE_AI_VIDEO_LIST,0,$project_id);//写一条列表页路由
|
|
|
|
$aiVideoListModel->truncate();
|
|
|
|
$aiVideoListModel->insertAll($saveData);
|
|
|
|
}
|
|
...
|
...
|
@@ -275,4 +280,64 @@ class AiVideoTask extends Command |
|
|
|
echo $message;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通知C端生成界面
|
|
|
|
* @param $project_id
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function updateRoutes($routes){
|
|
|
|
$domainModel = new DomainInfo();
|
|
|
|
$project_model = new Project();
|
|
|
|
foreach ($routes as $project_id => $route){
|
|
|
|
$route[] = 'top-video';
|
|
|
|
$domain = $domainModel->getProjectIdDomain($project_id);
|
|
|
|
if (empty($domain)) {
|
|
|
|
$this->output('send: 域名不存在, project id: ' . $project_id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//判断是否是自建站服务器,如果是,不请求C端接口,数据直接入库
|
|
|
|
$project_info = $project_model->read(['id'=>$project_id],['serve_id']);
|
|
|
|
if(!$project_info){
|
|
|
|
$this->output('send: 项目不存在, project id: ' . $project_id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$serve_ip_model = new ServersIp();
|
|
|
|
$serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']);
|
|
|
|
$servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0;
|
|
|
|
if($servers_id == ServerConfig::SELF_SITE_ID){
|
|
|
|
//判断是否已有更新进行中
|
|
|
|
$notify_model = new Notify();
|
|
|
|
$data = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'type' => Notify::TYPE_MASTER,
|
|
|
|
'route' => Notify::ROUTE_AI_BLOG,
|
|
|
|
'server_id' => ServerConfig::SELF_SITE_ID,
|
|
|
|
'status' => ['!=',Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
];
|
|
|
|
$notify = $notify_model->read($data,['id']);
|
|
|
|
if(!$notify){
|
|
|
|
$domain_array = parse_url($domain);
|
|
|
|
$data['data'] = Arr::a2s(['domain'=>$domain_array['host'],'url'=>$route,'language'=>[]]);
|
|
|
|
$data['status'] = Notify::STATUS_INIT;
|
|
|
|
$data['sort'] = 2;
|
|
|
|
$notify_model->add($data);
|
|
|
|
}
|
|
|
|
$this->output('send: 自建站项目, project id: ' . $project_id);
|
|
|
|
}else{
|
|
|
|
$c_url = $domain.'api/update_page/';
|
|
|
|
$param = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'type' => 1,
|
|
|
|
'route' => 3,
|
|
|
|
'url' => $route,
|
|
|
|
'language'=> [],
|
|
|
|
'is_sitemap' => 0
|
|
|
|
];
|
|
|
|
$res = http_post($c_url, json_encode($param,true));
|
|
|
|
$this->output('notify: project id: ' . $project_id . ', result: ' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|