正在显示
1 个修改的文件
包含
24 行增加
和
2 行删除
| @@ -11,6 +11,7 @@ namespace App\Console\Commands\AiBlog; | @@ -11,6 +11,7 @@ namespace App\Console\Commands\AiBlog; | ||
| 11 | 11 | ||
| 12 | use App\Models\Ai\AiBlog; | 12 | use App\Models\Ai\AiBlog; |
| 13 | use App\Models\Ai\AiBlogAuthor; | 13 | use App\Models\Ai\AiBlogAuthor; |
| 14 | +use App\Models\Ai\AiBlogList; | ||
| 14 | use App\Models\Project\ProjectAiSetting; | 15 | use App\Models\Project\ProjectAiSetting; |
| 15 | use App\Models\RouteMap\RouteMap; | 16 | use App\Models\RouteMap\RouteMap; |
| 16 | use App\Services\AiBlogService; | 17 | use App\Services\AiBlogService; |
| @@ -51,13 +52,34 @@ class AiBlogListTask extends Command | @@ -51,13 +52,34 @@ class AiBlogListTask extends Command | ||
| 51 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 52 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 52 | $aiBlogService->key = $aiSettingInfo['key']; | 53 | $aiBlogService->key = $aiSettingInfo['key']; |
| 53 | $page = 1; | 54 | $page = 1; |
| 55 | + $saveData = []; | ||
| 54 | $result = $aiBlogService->getAiBlogList($page,15); | 56 | $result = $aiBlogService->getAiBlogList($page,15); |
| 55 | - if(!isset($result['status'])){ | 57 | + if(!isset($result['status']) && $result['status'] != 200){ |
| 56 | continue; | 58 | continue; |
| 57 | } | 59 | } |
| 60 | + $total_page = $result['data']['total_page']; | ||
| 61 | + //组装数据保存 | ||
| 62 | + $saveData[] = [ | ||
| 63 | + 'route'=>$page, | ||
| 64 | + 'text'=>$result['section'], | ||
| 65 | + ]; | ||
| 66 | + while ($total_page > $page){ | ||
| 67 | + $page++; | ||
| 68 | + $result = $aiBlogService->getAiBlogList($page,15); | ||
| 69 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 70 | + $saveData[] = [ | ||
| 71 | + 'route'=>$page, | ||
| 72 | + 'text'=>$result['section'], | ||
| 73 | + ]; | ||
| 74 | + } | ||
| 75 | + } | ||
| 58 | //保存当前项目ai_blog数据 | 76 | //保存当前项目ai_blog数据 |
| 59 | ProjectServer::useProject($v['project_id']); | 77 | ProjectServer::useProject($v['project_id']); |
| 60 | - | 78 | + $aiBlogListModel = new AiBlogList(); |
| 79 | + if(!empty($saveData)){ | ||
| 80 | + $aiBlogListModel->truncate(); | ||
| 81 | + $aiBlogListModel->insertAll($saveData); | ||
| 82 | + } | ||
| 61 | DB::disconnect('custom_mysql'); | 83 | DB::disconnect('custom_mysql'); |
| 62 | //修改任务状态 | 84 | //修改任务状态 |
| 63 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$v['id']]); | 85 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$v['id']]); |
-
请 注册 或 登录 后发表评论