作者 赵彬吉
@@ -9,10 +9,16 @@ @@ -9,10 +9,16 @@
9 9
10 namespace App\Console\Commands\Ai; 10 namespace App\Console\Commands\Ai;
11 11
  12 +use App\Helper\Arr;
12 use App\Models\Ai\AiBlogAuthor; 13 use App\Models\Ai\AiBlogAuthor;
13 use App\Models\Ai\AiVideo; 14 use App\Models\Ai\AiVideo;
14 use App\Models\Ai\AiVideoList; 15 use App\Models\Ai\AiVideoList;
  16 +use App\Models\Com\Notify;
  17 +use App\Models\Devops\ServerConfig;
  18 +use App\Models\Devops\ServersIp;
  19 +use App\Models\Domain\DomainInfo;
15 use App\Models\Project\AiVideoTask as AiVideoTaskModel; 20 use App\Models\Project\AiVideoTask as AiVideoTaskModel;
  21 +use App\Models\Project\Project;
16 use App\Models\RouteMap\RouteMap; 22 use App\Models\RouteMap\RouteMap;
17 use App\Services\AiBlogService; 23 use App\Services\AiBlogService;
18 use App\Services\AiVideoService; 24 use App\Services\AiVideoService;
@@ -33,14 +39,12 @@ class AiVideoTask extends Command @@ -33,14 +39,12 @@ class AiVideoTask extends Command
33 39
34 public $updateProject = [];//需更新的列表 40 public $updateProject = [];//需更新的列表
35 public $routes = [];//需要更新的路由 41 public $routes = [];//需要更新的路由
36 -  
37 /** 42 /**
38 * The console command description. 43 * The console command description.
39 * 44 *
40 * @var string 45 * @var string
41 */ 46 */
42 protected $description = '查询ai_video是否已经生成'; 47 protected $description = '查询ai_video是否已经生成';
43 -  
44 /** 48 /**
45 * @return bool 49 * @return bool
46 * @throws \Exception 50 * @throws \Exception
@@ -72,7 +76,7 @@ class AiVideoTask extends Command @@ -72,7 +76,7 @@ class AiVideoTask extends Command
72 $this->updateProject = []; 76 $this->updateProject = [];
73 } 77 }
74 if(!empty($this->routes)){ 78 if(!empty($this->routes)){
75 - $this->updateRoutes($this->routes); 79 +// $this->updateRoutes($this->routes);
76 $this->routes = []; 80 $this->routes = [];
77 } 81 }
78 $aiVideoTaskModel = new AiVideoTaskModel(); 82 $aiVideoTaskModel = new AiVideoTaskModel();
@@ -259,6 +263,7 @@ class AiVideoTask extends Command @@ -259,6 +263,7 @@ class AiVideoTask extends Command
259 $aiVideoListModel = new AiVideoList(); 263 $aiVideoListModel = new AiVideoList();
260 if(!empty($saveData)){ 264 if(!empty($saveData)){
261 //写一条路由信息 265 //写一条路由信息
  266 + RouteMap::setRoute('top-video',RouteMap::SOURCE_AI_VIDEO_LIST,0,$project_id);//写一条列表页路由
262 $aiVideoListModel->truncate(); 267 $aiVideoListModel->truncate();
263 $aiVideoListModel->insertAll($saveData); 268 $aiVideoListModel->insertAll($saveData);
264 } 269 }
@@ -275,4 +280,64 @@ class AiVideoTask extends Command @@ -275,4 +280,64 @@ class AiVideoTask extends Command
275 echo $message; 280 echo $message;
276 return true; 281 return true;
277 } 282 }
  283 +
  284 + /**
  285 + * 通知C端生成界面
  286 + * @param $project_id
  287 + * @return bool
  288 + */
  289 + public function updateRoutes($routes){
  290 + $domainModel = new DomainInfo();
  291 + $project_model = new Project();
  292 + foreach ($routes as $project_id => $route){
  293 + $route[] = 'top-video';
  294 + $domain = $domainModel->getProjectIdDomain($project_id);
  295 + if (empty($domain)) {
  296 + $this->output('send: 域名不存在, project id: ' . $project_id);
  297 + continue;
  298 + }
  299 + //判断是否是自建站服务器,如果是,不请求C端接口,数据直接入库
  300 + $project_info = $project_model->read(['id'=>$project_id],['serve_id']);
  301 + if(!$project_info){
  302 + $this->output('send: 项目不存在, project id: ' . $project_id);
  303 + continue;
  304 + }
  305 + $serve_ip_model = new ServersIp();
  306 + $serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']);
  307 + $servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0;
  308 + if($servers_id == ServerConfig::SELF_SITE_ID){
  309 + //判断是否已有更新进行中
  310 + $notify_model = new Notify();
  311 + $data = [
  312 + 'project_id' => $project_id,
  313 + 'type' => Notify::TYPE_MASTER,
  314 + 'route' => Notify::ROUTE_AI_BLOG,
  315 + 'server_id' => ServerConfig::SELF_SITE_ID,
  316 + 'status' => ['!=',Notify::STATUS_FINISH_SITEMAP]
  317 + ];
  318 + $notify = $notify_model->read($data,['id']);
  319 + if(!$notify){
  320 + $domain_array = parse_url($domain);
  321 + $data['data'] = Arr::a2s(['domain'=>$domain_array['host'],'url'=>$route,'language'=>[]]);
  322 + $data['status'] = Notify::STATUS_INIT;
  323 + $data['sort'] = 2;
  324 + $notify_model->add($data);
  325 + }
  326 + $this->output('send: 自建站项目, project id: ' . $project_id);
  327 + }else{
  328 + $c_url = $domain.'api/update_page/';
  329 + $param = [
  330 + 'project_id' => $project_id,
  331 + 'type' => 1,
  332 + 'route' => 3,
  333 + 'url' => $route,
  334 + 'language'=> [],
  335 + 'is_sitemap' => 0
  336 + ];
  337 + $res = http_post($c_url, json_encode($param,true));
  338 + $this->output('notify: project id: ' . $project_id . ', result: ' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
  339 + }
  340 + }
  341 + return true;
  342 + }
278 } 343 }
@@ -48,6 +48,9 @@ class AiBlogController extends BaseController @@ -48,6 +48,9 @@ class AiBlogController extends BaseController
48 'id.required' => '主键不能为空', 48 'id.required' => '主键不能为空',
49 ]); 49 ]);
50 $info = $aiBlog->read(['id'=>$this->param['id']]); 50 $info = $aiBlog->read(['id'=>$this->param['id']]);
  51 + if(!empty($info['anchor'])){
  52 + $info['anchor'] = json_decode($info['anchor'],true);
  53 + }
51 $info['image'] = getImageUrl($info['image']); 54 $info['image'] = getImageUrl($info['image']);
52 $this->response('success',Code::SUCCESS,$info); 55 $this->response('success',Code::SUCCESS,$info);
53 } 56 }
@@ -13,6 +13,7 @@ use App\Enums\Common\Code; @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
14 use App\Http\Logic\Bside\Ai\AiVideoLogic; 14 use App\Http\Logic\Bside\Ai\AiVideoLogic;
15 use App\Models\Ai\AiVideo; 15 use App\Models\Ai\AiVideo;
  16 +use App\Models\Ai\AiVideoList;
16 17
17 class AiVideoController extends BaseController 18 class AiVideoController extends BaseController
18 { 19 {
@@ -51,6 +52,8 @@ class AiVideoController extends BaseController @@ -51,6 +52,8 @@ class AiVideoController extends BaseController
51 'id.required' => '主键不能为空', 52 'id.required' => '主键不能为空',
52 ]); 53 ]);
53 $info = $aiVideo->read(['id'=>$this->param['id']]); 54 $info = $aiVideo->read(['id'=>$this->param['id']]);
  55 + $info['anchor'] = json_decode($info['anchor'] ?? [],true);
  56 + $info['images'] = json_decode($info['images'] ?? [],true);
54 $this->response('success',Code::SUCCESS,$info); 57 $this->response('success',Code::SUCCESS,$info);
55 } 58 }
56 59
@@ -109,4 +112,40 @@ class AiVideoController extends BaseController @@ -109,4 +112,40 @@ class AiVideoController extends BaseController
109 $result = $aiVideoLogic->videoDelete(); 112 $result = $aiVideoLogic->videoDelete();
110 $this->response('success',Code::SUCCESS,$result); 113 $this->response('success',Code::SUCCESS,$result);
111 } 114 }
  115 +
  116 +
  117 + /**
  118 + * @remark :获取列表页数据
  119 + * @name :getAiBlogList
  120 + * @author :lyh
  121 + * @method :post
  122 + * @time :2025/2/21 16:22
  123 + */
  124 + public function getAiVideoList(AiVideoList $aiVideoList){
  125 + $lists = $aiVideoList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']);
  126 + if(!empty($lists) && !empty($lists['list'])){
  127 + foreach ($lists['list'] as $k => $v){
  128 + $v['route'] = $this->user['domain'] . 'top-video/' . (($v['route'] > 1) ? $v['route'] : '');
  129 + $lists['list'][$k] = $v;
  130 + }
  131 + }
  132 + $this->response('success',Code::SUCCESS,$lists);
  133 + }
  134 +
  135 + /**
  136 + * @remark :获取列表页数据详情
  137 + * @name :getAiBlogListInfo
  138 + * @author :lyh
  139 + * @method :post
  140 + * @time :2025/2/21 16:26
  141 + */
  142 + public function getAiBlogListInfo(AiVideoList $aiVideoList){
  143 + $this->request->validate([
  144 + 'id'=>['required'],
  145 + ],[
  146 + 'id.required' => '主键不能为空',
  147 + ]);
  148 + $info = $aiVideoList->read($this->map);
  149 + $this->response('success',Code::SUCCESS,$info);
  150 + }
112 } 151 }
@@ -147,6 +147,10 @@ class ComController extends BaseController @@ -147,6 +147,10 @@ class ComController extends BaseController
147 if($is_blogs != 1){ 147 if($is_blogs != 1){
148 $info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),','); 148 $info['role_menu'] = trim(str_replace(',57,',',',','.$info['role_menu'].','),',');
149 } 149 }
  150 + $is_video = $this->getIsAiVideo();
  151 + if($is_video != 1){
  152 + $info['role_menu'] = trim(str_replace(',74,',',',','.$info['role_menu'].','),',');
  153 + }
150 $this->map = [ 154 $this->map = [
151 'status'=>0, 155 'status'=>0,
152 'is_role'=>0, 156 'is_role'=>0,
@@ -195,6 +199,10 @@ class ComController extends BaseController @@ -195,6 +199,10 @@ class ComController extends BaseController
195 if($is_ai_blog != 1){ 199 if($is_ai_blog != 1){
196 $data[] = 57; 200 $data[] = 57;
197 } 201 }
  202 + $is_ai_video = $this->getIsAiVideo();
  203 + if($is_ai_video != 1){
  204 + $data[] = 74;
  205 + }
198 if(!empty($data)){ 206 if(!empty($data)){
199 $this->map['id'] = ['not in',$data]; 207 $this->map['id'] = ['not in',$data];
200 } 208 }
@@ -291,6 +299,16 @@ class ComController extends BaseController @@ -291,6 +299,16 @@ class ComController extends BaseController
291 return $this->user['is_ai_blog'] ?? 0; 299 return $this->user['is_ai_blog'] ?? 0;
292 } 300 }
293 301
  302 + /**
  303 + * @remark :ai视频
  304 + * @name :getIsAiVideo
  305 + * @author :lyh
  306 + * @method :post
  307 + * @time :2025/5/6 14:33
  308 + */
  309 + public function getIsAiVideo(){
  310 + return $this->user['is_ai_video'] ?? 0;
  311 + }
294 312
295 /** 313 /**
296 * @name :登录用户编辑资料/修改密码 314 * @name :登录用户编辑资料/修改密码
@@ -166,7 +166,7 @@ class ProjectLogic extends BaseLogic @@ -166,7 +166,7 @@ class ProjectLogic extends BaseLogic
166 }else{ 166 }else{
167 $this->param = $this->handleLevelStr($this->param);//处理星级客户暂停优化默认参数 167 $this->param = $this->handleLevelStr($this->param);//处理星级客户暂停优化默认参数
168 $this->saveSeoPlan($this->param);//保存seo白帽类型,上线保存一条审核记录 168 $this->saveSeoPlan($this->param);//保存seo白帽类型,上线保存一条审核记录
169 - $this->checkAiBlog($this->param);//开启白帽验证参数 169 + $this->checkAiBlog($this->param);//开启ai相关功能验证参数
170 DB::beginTransaction(); 170 DB::beginTransaction();
171 try { 171 try {
172 //初始化项目 172 //初始化项目
@@ -174,8 +174,9 @@ class ProjectLogic extends BaseLogic @@ -174,8 +174,9 @@ class ProjectLogic extends BaseLogic
174 //双向绑定服务器,需放到保存项目的上方 174 //双向绑定服务器,需放到保存项目的上方
175 $this->setServers($this->param['serve_id'],$this->param['id']); 175 $this->setServers($this->param['serve_id'],$this->param['id']);
176 //ai_blog 176 //ai_blog
177 - $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],  
178 - $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '',$this->param['deploy_optimize']['company_en_description'] ?? ''); 177 + $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'] ?? 0,
  178 + $this->param['company']??"", $this->param['deploy_optimize']['company_en_name'] ?? '',
  179 + $this->param['deploy_optimize']['company_en_description'] ?? '',$this->param['is_ai_video'] ?? 0);
179 //保存项目信息 180 //保存项目信息
180 $this->saveProject($this->param); 181 $this->saveProject($this->param);
181 //保存建站部署信息 182 //保存建站部署信息
@@ -217,6 +218,7 @@ class ProjectLogic extends BaseLogic @@ -217,6 +218,7 @@ class ProjectLogic extends BaseLogic
217 if (in_array('2', $param['level']) || in_array('3', $param['level'])) { 218 if (in_array('2', $param['level']) || in_array('3', $param['level'])) {
218 //优化设置默认关闭 219 //优化设置默认关闭
219 $param['is_ai_blog'] = 0; 220 $param['is_ai_blog'] = 0;
  221 + $param['is_ai_video'] = 0;
220 $param['deploy_optimize']['is_ai_blog_send'] = 0; 222 $param['deploy_optimize']['is_ai_blog_send'] = 0;
221 $param['deploy_optimize']['is_auto_keywords'] = 0; 223 $param['deploy_optimize']['is_auto_keywords'] = 0;
222 } 224 }
@@ -259,7 +261,7 @@ class ProjectLogic extends BaseLogic @@ -259,7 +261,7 @@ class ProjectLogic extends BaseLogic
259 } 261 }
260 262
261 /** 263 /**
262 - * @remark :开启白帽验证参数 264 + * @remark :开启ai博客及视频
263 * @name :checkAiBlog 265 * @name :checkAiBlog
264 * @author :lyh 266 * @author :lyh
265 * @method :post 267 * @method :post
@@ -287,11 +289,11 @@ class ProjectLogic extends BaseLogic @@ -287,11 +289,11 @@ class ProjectLogic extends BaseLogic
287 * @method :post 289 * @method :post
288 * @time :2025/2/13 16:02 290 * @time :2025/2/13 16:02
289 */ 291 */
290 - public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description){  
291 - if(empty($main_lang_id) || empty($is_ai_blog)){ 292 + public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$company,$company_en_name,$company_en_description,$is_ai_video = 0){
  293 + if(empty($main_lang_id) || (empty($is_ai_blog) && empty($is_ai_video))){
292 return true; 294 return true;
293 } 295 }
294 - $projectInfo = $this->model->read(['id'=>$project_id],['title','is_ai_blog','main_lang_id','company']); 296 + $projectInfo = $this->model->read(['id'=>$project_id],['title','main_lang_id','company']);
295 $projectOptimize = DeployOptimize::where('project_id', $project_id)->first(); 297 $projectOptimize = DeployOptimize::where('project_id', $project_id)->first();
296 //获取项目主语种 298 //获取项目主语种
297 $languageModel = new WebLanguage(); 299 $languageModel = new WebLanguage();
@@ -58,7 +58,7 @@ class AiBlogLogic extends BaseLogic @@ -58,7 +58,7 @@ class AiBlogLogic extends BaseLogic
58 } 58 }
59 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']); 59 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']);
60 $anchor = $this->param['anchor'] ?? []; 60 $anchor = $this->param['anchor'] ?? [];
61 - $this->param['anchor'] = json_encode($this->param['anchor'],true); 61 + $this->param['anchor'] = json_encode($anchor,true);
62 $this->model->edit($this->param,['id'=>$this->param['id']]); 62 $this->model->edit($this->param,['id'=>$this->param['id']]);
63 $aiSettingInfo = $this->getProjectAiSetting(); 63 $aiSettingInfo = $this->getProjectAiSetting();
64 $aiBlogService = new AiBlogService(); 64 $aiBlogService = new AiBlogService();
@@ -41,7 +41,7 @@ class AiVideoLogic extends BaseLogic @@ -41,7 +41,7 @@ class AiVideoLogic extends BaseLogic
41 try { 41 try {
42 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']); 42 $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']);
43 $anchor = $this->param['anchor'] ?? []; 43 $anchor = $this->param['anchor'] ?? [];
44 - $this->param['anchor'] = json_encode($this->param['anchor'],true); 44 + $this->param['anchor'] = json_encode($anchor,true);
45 $this->param['images'] = json_encode($this->param['images'],true); 45 $this->param['images'] = json_encode($this->param['images'],true);
46 $this->model->edit($this->param,['id'=>$this->param['id']]); 46 $this->model->edit($this->param,['id'=>$this->param['id']]);
47 $aiVideoService = new AiVideoService($this->user['project_id']); 47 $aiVideoService = new AiVideoService($this->user['project_id']);
@@ -274,7 +274,8 @@ class UserLoginLogic @@ -274,7 +274,8 @@ class UserLoginLogic
274 $info['is_show_blog'] = $project['is_show_blog']; 274 $info['is_show_blog'] = $project['is_show_blog'];
275 $info['upload_config'] = $project['upload_config']; 275 $info['upload_config'] = $project['upload_config'];
276 $info['main_lang_id'] = $project['main_lang_id']; 276 $info['main_lang_id'] = $project['main_lang_id'];
277 - $info['is_ai_blog'] = $project['is_ai_blog']; 277 + $info['is_ai_blog'] = $project['is_ai_blog'] ?? 0;
  278 + $info['is_ai_video'] = $project['is_ai_video'] ?? 0;
278 $info['image_max'] = $project['image_max']; 279 $info['image_max'] = $project['image_max'];
279 $info['is_del_inquiry'] = $project['is_del_inquiry'] ?? 0; 280 $info['is_del_inquiry'] = $project['is_del_inquiry'] ?? 0;
280 $info['uptime_type'] = $this->getHistory($project); 281 $info['uptime_type'] = $this->getHistory($project);
@@ -159,6 +159,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -159,6 +159,8 @@ Route::middleware(['bloginauth'])->group(function () {
159 Route::any('/sendTask', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'sendTask'])->name('ai_video_sendTask'); 159 Route::any('/sendTask', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'sendTask'])->name('ai_video_sendTask');
160 Route::any('/save', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'save'])->name('ai_video_save'); 160 Route::any('/save', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'save'])->name('ai_video_save');
161 Route::any('/del', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'delete'])->name('ai_video_delete'); 161 Route::any('/del', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'delete'])->name('ai_video_delete');
  162 + Route::any('/getAiVideoList', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'getAiVideoList'])->name('ai_video_getAiVideoList');
  163 + Route::any('/getAiBlogListInfo', [\App\Http\Controllers\Bside\Ai\AiVideoController::class, 'getAiBlogListInfo'])->name('ai_video_getAiBlogListInfo');
162 }); 164 });
163 //ai 165 //ai
164 Route::any('/news/', [\App\Http\Controllers\Bside\Ai\AiNewsController::class, 'save'])->name('ai_news_save'); 166 Route::any('/news/', [\App\Http\Controllers\Bside\Ai\AiNewsController::class, 'save'])->name('ai_news_save');