合并分支 'lyh-server' 到 'master'
Lyh server 查看合并请求 !1929
正在显示
11 个修改的文件
包含
331 行增加
和
26 行删除
| @@ -79,6 +79,7 @@ class AiBlogAuthorTask extends Command | @@ -79,6 +79,7 @@ class AiBlogAuthorTask extends Command | ||
| 79 | ProjectServer::useProject($info['project_id']); | 79 | ProjectServer::useProject($info['project_id']); |
| 80 | $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); | 80 | $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); |
| 81 | RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由 | 81 | RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由 |
| 82 | + RouteMap::setRoute('top-video',RouteMap::SOURCE_AI_VIDEO_LIST,0,$info['project_id']);//写一条列表页路由 | ||
| 82 | DB::disconnect('custom_mysql'); | 83 | DB::disconnect('custom_mysql'); |
| 83 | //修改任务状态 | 84 | //修改任务状态 |
| 84 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); | 85 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); |
app/Console/Commands/Ai/AiVideoListTask.php
0 → 100644
| 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\Ai; | ||
| 11 | + | ||
| 12 | +use App\Models\Ai\AiBlog; | ||
| 13 | +use App\Models\Ai\AiBlogAuthor; | ||
| 14 | +use App\Models\Ai\AiBlogList; | ||
| 15 | +use App\Models\Ai\AiVideoList; | ||
| 16 | +use App\Models\Domain\DomainInfo; | ||
| 17 | +use App\Models\Project\ProjectAiSetting; | ||
| 18 | +use App\Models\RouteMap\RouteMap; | ||
| 19 | +use App\Services\AiBlogService; | ||
| 20 | +use App\Services\AiVideoService; | ||
| 21 | +use App\Services\ProjectServer; | ||
| 22 | +use Illuminate\Console\Command; | ||
| 23 | +use App\Models\Project\AiBlogTask as AiBlogTaskModel; | ||
| 24 | +use Illuminate\Support\Facades\Cache; | ||
| 25 | +use Illuminate\Support\Facades\DB; | ||
| 26 | +use function Symfony\Component\String\s; | ||
| 27 | + | ||
| 28 | +/*** | ||
| 29 | + * @remark :根据项目更新blog列表 | ||
| 30 | + * @name :AiBlogListTask | ||
| 31 | + * @author :lyh | ||
| 32 | + * @method :post | ||
| 33 | + * @time :2025/3/6 9:45 | ||
| 34 | + */ | ||
| 35 | +class AiVideoListTask extends Command | ||
| 36 | +{ | ||
| 37 | + /** | ||
| 38 | + * The name and signature of the console command. | ||
| 39 | + * | ||
| 40 | + * @var string | ||
| 41 | + */ | ||
| 42 | + protected $signature = 'save_ai_video_list {project_id}'; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * The console command description. | ||
| 46 | + * | ||
| 47 | + * @var string | ||
| 48 | + */ | ||
| 49 | + protected $description = '生成video列表'; | ||
| 50 | + | ||
| 51 | + public function handle(){ | ||
| 52 | + $project_id = $this->argument('project_id'); | ||
| 53 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('执行的项目id->'.$project_id, true) . PHP_EOL, FILE_APPEND); | ||
| 54 | + ProjectServer::useProject($project_id); | ||
| 55 | + $this->updateBlogList($project_id); | ||
| 56 | +// $this->curlDelRoute($project_id); | ||
| 57 | + DB::disconnect('custom_mysql'); | ||
| 58 | + return true; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * @remark :更新列表页数据 | ||
| 63 | + * @name :updateBlogList | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2025/3/5 11:07 | ||
| 67 | + */ | ||
| 68 | + public function updateBlogList($project_id){ | ||
| 69 | + $aiVideoService = new AiVideoService($project_id); | ||
| 70 | + $page = 1; | ||
| 71 | + $saveData = []; | ||
| 72 | + $result = $aiVideoService->getAiVideoList($page,15); | ||
| 73 | + if(!isset($result['status']) && $result['status'] != 200){ | ||
| 74 | + return true; | ||
| 75 | + } | ||
| 76 | + $total_page = $result['data']['total_page']; | ||
| 77 | + //组装数据保存 | ||
| 78 | + $saveData[] = [ | ||
| 79 | + 'route'=>$page, | ||
| 80 | + 'text'=>$result['data']['section'], | ||
| 81 | + ]; | ||
| 82 | + while ($total_page > $page){ | ||
| 83 | + $page++; | ||
| 84 | + $result = $aiVideoService->getAiVideoList($page,15); | ||
| 85 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 86 | + $saveData[] = [ | ||
| 87 | + 'route'=>$page, | ||
| 88 | + 'text'=>$result['data']['section'], | ||
| 89 | + ]; | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + $aiVideoListModel = new AiVideoList(); | ||
| 93 | + if(!empty($saveData)){ | ||
| 94 | + //写一条路由信息 | ||
| 95 | + $aiVideoListModel->truncate(); | ||
| 96 | + $aiVideoListModel->insertAll($saveData); | ||
| 97 | + } | ||
| 98 | + return true; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * @remark :通知C端生成界面 | ||
| 103 | + * @name :sendNotice | ||
| 104 | + * @author :lyh | ||
| 105 | + * @method :post | ||
| 106 | + * @time :2025/3/6 11:51 | ||
| 107 | + */ | ||
| 108 | + public function curlDelRoute($project_id){ | ||
| 109 | + $domainModel = new DomainInfo(); | ||
| 110 | + //获取项目域名 | ||
| 111 | + $domain = $domainModel->getProjectIdDomain($project_id); | ||
| 112 | + if(!empty($domain)){ | ||
| 113 | + $c_url = $domain.'api/update_page/'; | ||
| 114 | + $param = [ | ||
| 115 | + 'project_id' => $project_id, | ||
| 116 | + 'type' => 1, | ||
| 117 | + 'route' => 3, | ||
| 118 | + 'url' => ['top-blog'], | ||
| 119 | + 'language'=> [], | ||
| 120 | + 'is_sitemap' => 0 | ||
| 121 | + ]; | ||
| 122 | + http_post($c_url, json_encode($param)); | ||
| 123 | + } | ||
| 124 | + return true; | ||
| 125 | + } | ||
| 126 | +} |
| @@ -9,9 +9,12 @@ | @@ -9,9 +9,12 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Console\Commands\Ai; | 10 | namespace App\Console\Commands\Ai; |
| 11 | 11 | ||
| 12 | +use App\Models\Ai\AiBlogAuthor; | ||
| 12 | use App\Models\Ai\AiVideo; | 13 | use App\Models\Ai\AiVideo; |
| 14 | +use App\Models\Ai\AiVideoList; | ||
| 13 | use App\Models\Project\AiVideoTask as AiVideoTaskModel; | 15 | use App\Models\Project\AiVideoTask as AiVideoTaskModel; |
| 14 | use App\Models\RouteMap\RouteMap; | 16 | use App\Models\RouteMap\RouteMap; |
| 17 | +use App\Services\AiBlogService; | ||
| 15 | use App\Services\AiVideoService; | 18 | use App\Services\AiVideoService; |
| 16 | use App\Services\DingService; | 19 | use App\Services\DingService; |
| 17 | use App\Services\ProjectServer; | 20 | use App\Services\ProjectServer; |
| @@ -64,14 +67,14 @@ class AiVideoTask extends Command | @@ -64,14 +67,14 @@ class AiVideoTask extends Command | ||
| 64 | { | 67 | { |
| 65 | $task_id = Redis::rpop('ai_video_task'); | 68 | $task_id = Redis::rpop('ai_video_task'); |
| 66 | if (empty($task_id)) { | 69 | if (empty($task_id)) { |
| 67 | -// if(!empty($this->updateProject)){ | ||
| 68 | -// $this->updateProject($this->updateProject); | ||
| 69 | -// $this->updateProject = []; | ||
| 70 | -// } | ||
| 71 | -// if(!empty($this->routes)){ | ||
| 72 | -// $this->updateRoutes($this->routes); | ||
| 73 | -// $this->routes = []; | ||
| 74 | -// } | 70 | + if(!empty($this->updateProject)){ |
| 71 | + $this->updateProject($this->updateProject); | ||
| 72 | + $this->updateProject = []; | ||
| 73 | + } | ||
| 74 | + if(!empty($this->routes)){ | ||
| 75 | + $this->updateRoutes($this->routes); | ||
| 76 | + $this->routes = []; | ||
| 77 | + } | ||
| 75 | $aiVideoTaskModel = new AiVideoTaskModel(); | 78 | $aiVideoTaskModel = new AiVideoTaskModel(); |
| 76 | $finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour')); | 79 | $finish_at = date('Y-m-d H:i:s', strtotime('-' . $finish_at . ' hour')); |
| 77 | $ids = $aiVideoTaskModel->formatQuery(['status'=>$aiVideoTaskModel::STATUS_RUNNING,'updated_at'=>['<=',$finish_at]])->pluck('id'); | 80 | $ids = $aiVideoTaskModel->formatQuery(['status'=>$aiVideoTaskModel::STATUS_RUNNING,'updated_at'=>['<=',$finish_at]])->pluck('id'); |
| @@ -152,6 +155,13 @@ class AiVideoTask extends Command | @@ -152,6 +155,13 @@ class AiVideoTask extends Command | ||
| 152 | 'status'=>$aiVideoTaskModel::STATUS_FINISH | 155 | 'status'=>$aiVideoTaskModel::STATUS_FINISH |
| 153 | ]; | 156 | ]; |
| 154 | $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]); | 157 | $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]); |
| 158 | + //需要更新的路由 | ||
| 159 | + if (!in_array($result['data']['author_id'], $this->updateProject[$item['project_id']] ?? [])) { | ||
| 160 | + $this->updateProject[$item['project_id']][] = $result['data']['author_id']; | ||
| 161 | + } | ||
| 162 | + if (!in_array($route, $this->routes[$item['project_id']] ?? [])) { | ||
| 163 | + $this->routes[$item['project_id']][] = $route; | ||
| 164 | + } | ||
| 155 | DB::disconnect('custom_mysql'); | 165 | DB::disconnect('custom_mysql'); |
| 156 | $aiVideoTaskModel->edit(['status'=>$aiVideoTaskModel::STATUS_FINISH],['id'=>$item['id']]); | 166 | $aiVideoTaskModel->edit(['status'=>$aiVideoTaskModel::STATUS_FINISH],['id'=>$item['id']]); |
| 157 | $this->output('success: task id: ' . $task_id); | 167 | $this->output('success: task id: ' . $task_id); |
| @@ -159,6 +169,102 @@ class AiVideoTask extends Command | @@ -159,6 +169,102 @@ class AiVideoTask extends Command | ||
| 159 | } | 169 | } |
| 160 | 170 | ||
| 161 | /** | 171 | /** |
| 172 | + * @remark :更新项目作者页面及列表页 | ||
| 173 | + * @name :updateProject | ||
| 174 | + * @author :lyh | ||
| 175 | + * @method :post | ||
| 176 | + * @time :2025/4/30 15:43 | ||
| 177 | + */ | ||
| 178 | + public function updateProject($updateProject){ | ||
| 179 | + if(empty($updateProject)){ | ||
| 180 | + return true; | ||
| 181 | + } | ||
| 182 | + foreach ($updateProject as $project_id => $author){ | ||
| 183 | + ProjectServer::useProject($project_id); | ||
| 184 | + $this->output('sync: list start, project_id: ' . $project_id); | ||
| 185 | + $this->updateBlogList($project_id); | ||
| 186 | + $this->output('sync: list end'); | ||
| 187 | + //更新作者 | ||
| 188 | + $this->output('sync: author start, project_id: ' . $project_id); | ||
| 189 | + foreach ($author as $val){ | ||
| 190 | + $this->updateAiBlogAuthor($val,$project_id); | ||
| 191 | + } | ||
| 192 | + $this->output('sync: author end'); | ||
| 193 | + DB::disconnect('custom_mysql'); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + return true; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * @remark :更新作者页面 | ||
| 201 | + * @name :updateAiBlogAuthor | ||
| 202 | + * @author :lyh | ||
| 203 | + * @method :post | ||
| 204 | + * @time :2025/4/30 15:52 | ||
| 205 | + */ | ||
| 206 | + public function updateAiBlogAuthor($author_id,$project_id){ | ||
| 207 | + if(empty($author_id)){ | ||
| 208 | + return true; | ||
| 209 | + } | ||
| 210 | + $aiBlogService = new AiBlogService($project_id); | ||
| 211 | + $aiBlogService->author_id = $author_id; | ||
| 212 | + $result = $aiBlogService->getAuthorDetail(); | ||
| 213 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 214 | + //当前作者的页面 | ||
| 215 | + $aiBlogAuthorModel = new AiBlogAuthor(); | ||
| 216 | + $authorInfo = $aiBlogAuthorModel->read(['author_id'=>$author_id],['id','route']); | ||
| 217 | + if($authorInfo !== false && !empty($result['data']['section'])){ | ||
| 218 | + //需要更新的路由 | ||
| 219 | + if (!in_array($authorInfo['route'], $this->routes[$project_id] ?? [])) { | ||
| 220 | + $this->routes[$project_id][] = $authorInfo['route']; | ||
| 221 | + } | ||
| 222 | + $aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$author_id]); | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + return true; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * @remark :更新 | ||
| 230 | + * @name :updateBlogList | ||
| 231 | + * @author :lyh | ||
| 232 | + * @method :post | ||
| 233 | + * @time :2025/4/30 15:45 | ||
| 234 | + */ | ||
| 235 | + public function updateBlogList($project_id){ | ||
| 236 | + $aiVideoService = new AiVideoService($project_id); | ||
| 237 | + $page = 1; | ||
| 238 | + $saveData = []; | ||
| 239 | + $result = $aiVideoService->getAiVideoList($page,15); | ||
| 240 | + if(!isset($result['status']) && $result['status'] != 200){ | ||
| 241 | + return true; | ||
| 242 | + } | ||
| 243 | + $total_page = $result['data']['total_page']; | ||
| 244 | + //组装数据保存 | ||
| 245 | + $saveData[] = [ | ||
| 246 | + 'route'=>$page, | ||
| 247 | + 'text'=>$result['data']['section'], | ||
| 248 | + ]; | ||
| 249 | + while ($total_page > $page){ | ||
| 250 | + $page++; | ||
| 251 | + $result = $aiVideoService->getAiVideoList($page,15); | ||
| 252 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 253 | + $saveData[] = [ | ||
| 254 | + 'route'=>$page, | ||
| 255 | + 'text'=>$result['data']['section'], | ||
| 256 | + ]; | ||
| 257 | + } | ||
| 258 | + } | ||
| 259 | + $aiVideoListModel = new AiVideoList(); | ||
| 260 | + if(!empty($saveData)){ | ||
| 261 | + //写一条路由信息 | ||
| 262 | + $aiVideoListModel->truncate(); | ||
| 263 | + $aiVideoListModel->insertAll($saveData); | ||
| 264 | + } | ||
| 265 | + return true; | ||
| 266 | + } | ||
| 267 | + /** | ||
| 162 | * 输入日志 | 268 | * 输入日志 |
| 163 | * @param $message | 269 | * @param $message |
| 164 | * @return bool | 270 | * @return bool |
| @@ -90,11 +90,12 @@ class AfterDayCount extends Command | @@ -90,11 +90,12 @@ class AfterDayCount extends Command | ||
| 90 | ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") | 90 | ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") |
| 91 | ->count(); | 91 | ->count(); |
| 92 | $rate = number_format($qualified_count / $project_count, 2); | 92 | $rate = number_format($qualified_count / $project_count, 2); |
| 93 | - $threeMonthsAgo = date('Y-m-d 00:00:00', strtotime('-3 months')); | 93 | + $threeMonthsAgo = date('Y-m-d', strtotime('-3 months')); |
| 94 | $three_project_count = $projectModel->where('gl_project.extend_type',0) | 94 | $three_project_count = $projectModel->where('gl_project.extend_type',0) |
| 95 | ->where('gl_project.delete_status',0) | 95 | ->where('gl_project.delete_status',0) |
| 96 | ->where('gl_project.old_project_id',0) | 96 | ->where('gl_project.old_project_id',0) |
| 97 | - ->where('gl_project.created_at','<=',$threeMonthsAgo) | 97 | + ->where('gl_project.created_at','>=',$threeMonthsAgo.' 00:00:00') |
| 98 | + ->where('gl_project.created_at','<=',$threeMonthsAgo.' 23:59:59') | ||
| 98 | ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) | 99 | ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) |
| 99 | ->whereIn('gl_project.type',[2,4]) | 100 | ->whereIn('gl_project.type',[2,4]) |
| 100 | ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') | 101 | ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') |
| @@ -105,7 +106,8 @@ class AfterDayCount extends Command | @@ -105,7 +106,8 @@ class AfterDayCount extends Command | ||
| 105 | ->whereIn('gl_project.id',$projectIdArr) | 106 | ->whereIn('gl_project.id',$projectIdArr) |
| 106 | ->where('gl_project.delete_status',0) | 107 | ->where('gl_project.delete_status',0) |
| 107 | ->where('gl_project.old_project_id',0) | 108 | ->where('gl_project.old_project_id',0) |
| 108 | - ->where('gl_project.created_at','<=',$threeMonthsAgo) | 109 | + ->where('gl_project.created_at','>=',$threeMonthsAgo.' 00:00:00') |
| 110 | + ->where('gl_project.created_at','<=',$threeMonthsAgo.' 23:59:59') | ||
| 109 | ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) | 111 | ->whereIn('gl_project_deploy_optimize.optimist_mid',$idArr) |
| 110 | ->whereIn('gl_project.type',[2,4]) | 112 | ->whereIn('gl_project.type',[2,4]) |
| 111 | ->where('gl_project_deploy_build.plan','!=',0) | 113 | ->where('gl_project_deploy_build.plan','!=',0) |
| @@ -124,7 +126,7 @@ class AfterDayCount extends Command | @@ -124,7 +126,7 @@ class AfterDayCount extends Command | ||
| 124 | ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') | 126 | ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') |
| 125 | ->whereRaw("FIND_IN_SET('2', gl_project.level) = 0 AND FIND_IN_SET('3', gl_project.level) = 0") | 127 | ->whereRaw("FIND_IN_SET('2', gl_project.level) = 0 AND FIND_IN_SET('3', gl_project.level) = 0") |
| 126 | ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") | 128 | ->whereRaw("FIND_IN_SET('7', gl_project_deploy_optimize.special) = 0 AND FIND_IN_SET('8', gl_project_deploy_optimize.special) = 0") |
| 127 | - ->pluck('gl_project.title')->toArray(); | 129 | + ->select(['gl_project.title','gl_project.finish_remain_day','gl_project_deploy_optimize.start_date'])->get()->toArray(); |
| 128 | $saveData[] = [ | 130 | $saveData[] = [ |
| 129 | 'date'=>date('Y-m-d', strtotime('yesterday')), | 131 | 'date'=>date('Y-m-d', strtotime('yesterday')), |
| 130 | 'type'=> $key, | 132 | 'type'=> $key, |
| @@ -82,11 +82,13 @@ class UpdateRoute extends Command | @@ -82,11 +82,13 @@ class UpdateRoute extends Command | ||
| 82 | $projectModel = new Project(); | 82 | $projectModel = new Project(); |
| 83 | $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4]]], 'id', ['id']); | 83 | $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4]]], 'id', ['id']); |
| 84 | foreach ($lists as $val) { | 84 | foreach ($lists as $val) { |
| 85 | - echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL; | 85 | +// echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL; |
| 86 | ProjectServer::useProject($val['id']); | 86 | ProjectServer::useProject($val['id']); |
| 87 | $aiBlogModel = new AiBlogAuthor(); | 87 | $aiBlogModel = new AiBlogAuthor(); |
| 88 | $results = $aiBlogModel->whereColumn('title', '!=', 'seo_title')->get(); | 88 | $results = $aiBlogModel->whereColumn('title', '!=', 'seo_title')->get(); |
| 89 | + echo '项目id:'.json_encode($results,true).PHP_EOL; | ||
| 89 | if(!$results){ | 90 | if(!$results){ |
| 91 | + $aiBlogModel->edit(['seo_title'=>'','seo_keyword'=>'','seo_description'=>''],['id'=>['>',0]]); | ||
| 90 | echo '项目id:'.$val['id'].PHP_EOL; | 92 | echo '项目id:'.$val['id'].PHP_EOL; |
| 91 | } | 93 | } |
| 92 | DB::disconnect('custom_mysql'); | 94 | DB::disconnect('custom_mysql'); |
| @@ -86,6 +86,25 @@ class AiBlogController extends BaseController | @@ -86,6 +86,25 @@ class AiBlogController extends BaseController | ||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | + * @remark : | ||
| 90 | + * @name :saveText | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2025/4/30 18:05 | ||
| 94 | + */ | ||
| 95 | + public function saveText(AiBlogLogic $aiBlogLogic){ | ||
| 96 | + $this->request->validate([ | ||
| 97 | + 'id'=>['required'], | ||
| 98 | + 'text'=>['required'], | ||
| 99 | + ],[ | ||
| 100 | + 'id.required' => '关键字不能为空', | ||
| 101 | + 'text.required' => '场景不能为空', | ||
| 102 | + ]); | ||
| 103 | + $aiBlogLogic->blogSaveText(); | ||
| 104 | + $this->response('success'); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 89 | * @remark :获取作者列表 | 108 | * @remark :获取作者列表 |
| 90 | * @name :getAiBlogAuthor | 109 | * @name :getAiBlogAuthor |
| 91 | * @author :lyh | 110 | * @author :lyh |
| @@ -63,11 +63,10 @@ class AiBlogLogic extends BaseLogic | @@ -63,11 +63,10 @@ class AiBlogLogic extends BaseLogic | ||
| 63 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 63 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 64 | $aiBlogService->key = $aiSettingInfo['key']; | 64 | $aiBlogService->key = $aiSettingInfo['key']; |
| 65 | $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); | 65 | $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); |
| 66 | - $aiBlogTaskModel = new AiBlogTask(); | ||
| 67 | - $aiBlogTaskModel->edit(['status'=>AiBlogTask::STATUS_RUNNING],['task_id'=>$this->param['task_id']]);//重新走拉取流程 | ||
| 68 | }catch (\Exception $e){ | 66 | }catch (\Exception $e){ |
| 69 | $this->fail('保存失败,请联系管理员'); | 67 | $this->fail('保存失败,请联系管理员'); |
| 70 | } | 68 | } |
| 69 | + shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &"); | ||
| 71 | return $this->success(); | 70 | return $this->success(); |
| 72 | } | 71 | } |
| 73 | 72 |
| @@ -54,13 +54,11 @@ class AiVideoLogic extends BaseLogic | @@ -54,13 +54,11 @@ class AiVideoLogic extends BaseLogic | ||
| 54 | */ | 54 | */ |
| 55 | public function videoSave(){ | 55 | public function videoSave(){ |
| 56 | try { | 56 | try { |
| 57 | - $this->param['route'] = RouteMap::setRoute($this->param['tit'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']); | 57 | + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']); |
| 58 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 58 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 59 | - $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 60 | - $aiBlogService = new AiBlogService(); | ||
| 61 | - $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 62 | - $aiBlogService->key = $aiSettingInfo['key']; | ||
| 63 | - $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); | 59 | + $aiVideoService = new AiVideoService($this->user['project_id']); |
| 60 | + $aiVideoService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['title'], | ||
| 61 | + 'content'=>$this->param['content'] ?? '','video_url'=>$this->param['video_url'],'thumb'=>$this->param['image'],'url'=>$this->param['route'],'author_id'=>$this->param['author_id']]); | ||
| 64 | }catch (\Exception $e){ | 62 | }catch (\Exception $e){ |
| 65 | $this->fail('保存失败,请联系管理员'); | 63 | $this->fail('保存失败,请联系管理员'); |
| 66 | } | 64 | } |
| @@ -96,13 +94,10 @@ class AiVideoLogic extends BaseLogic | @@ -96,13 +94,10 @@ class AiVideoLogic extends BaseLogic | ||
| 96 | */ | 94 | */ |
| 97 | public function videoDelete(){ | 95 | public function videoDelete(){ |
| 98 | try { | 96 | try { |
| 99 | - $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 100 | - $aiBlogService = new AiBlogService(); | 97 | + $aiBlogService = new AiVideoService($this->user['project_id']); |
| 101 | foreach ($this->param['ids'] as $id) { | 98 | foreach ($this->param['ids'] as $id) { |
| 102 | $info = $this->model->read(['id'=>$id],['task_id']); | 99 | $info = $this->model->read(['id'=>$id],['task_id']); |
| 103 | - $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 104 | - $aiBlogService->key = $aiSettingInfo['key']; | ||
| 105 | - $aiBlogService->delDetail($info['task_id']); | 100 | + $aiBlogService->delVideoDetail($info['task_id']); |
| 106 | //删除路由映射 | 101 | //删除路由映射 |
| 107 | RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']); | 102 | RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']); |
| 108 | $this->model->del(['id'=>$id]); | 103 | $this->model->del(['id'=>$id]); |
app/Models/Ai/AiVideoList.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiBlogList.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/2/21 15:57 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Ai; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class AiVideoList extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_ai_video_list'; | ||
| 17 | + //连接数据库 | ||
| 18 | + protected $connection = 'custom_mysql'; | ||
| 19 | +} |
| @@ -37,6 +37,7 @@ class RouteMap extends Base | @@ -37,6 +37,7 @@ class RouteMap extends Base | ||
| 37 | const SOURCE_AI_VIDEO = 'ai_video'; | 37 | const SOURCE_AI_VIDEO = 'ai_video'; |
| 38 | const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者 | 38 | const SOURCE_AI_BLOG_AUTHOR = 'ai_blog_author';//ai博客作者 |
| 39 | const SOURCE_AI_BLOG_LIST = 'ai_blog_list'; | 39 | const SOURCE_AI_BLOG_LIST = 'ai_blog_list'; |
| 40 | + const SOURCE_AI_VIDEO_LIST = 'ai_blog_video'; | ||
| 40 | //自定义模块分类 | 41 | //自定义模块分类 |
| 41 | const SOURCE_MODULE_CATE = 'module_category'; | 42 | const SOURCE_MODULE_CATE = 'module_category'; |
| 42 | 43 |
| @@ -99,6 +99,41 @@ class AiVideoService | @@ -99,6 +99,41 @@ class AiVideoService | ||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | /** | 101 | /** |
| 102 | + * @remark :获取列表页数据 | ||
| 103 | + * @name :getAiVideoList | ||
| 104 | + * @author :lyh | ||
| 105 | + * @method :post | ||
| 106 | + * @time :2025/4/30 15:48 | ||
| 107 | + */ | ||
| 108 | + public function getAiVideoList($page,$page_size){ | ||
| 109 | + $request_url = $this->url.'api/video/list'; | ||
| 110 | + $param['mch_id'] = $this->mch_id; | ||
| 111 | + $param['page'] = $page; | ||
| 112 | + $param['page_size'] = $page_size; | ||
| 113 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 114 | + $param['sign'] = $this->sign; | ||
| 115 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 116 | + return $result; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * @remark :删除详情数据 | ||
| 121 | + * @name :delDetail | ||
| 122 | + * @author :lyh | ||
| 123 | + * @method :post | ||
| 124 | + * @time :2025/4/30 16:00 | ||
| 125 | + */ | ||
| 126 | + public function delVideoDetail($task_id){ | ||
| 127 | + $param['task_id'] = $task_id; | ||
| 128 | + $request_url = $this->url.'api/video/delete'; | ||
| 129 | + $param['mch_id'] = $this->mch_id; | ||
| 130 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 131 | + $param['sign'] = $this->sign; | ||
| 132 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 133 | + return $result; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + /** | ||
| 102 | * @remark :计算签名 | 137 | * @remark :计算签名 |
| 103 | * @name :generateSign | 138 | * @name :generateSign |
| 104 | * @author :lyh | 139 | * @author :lyh |
-
请 注册 或 登录 后发表评论