正在显示
4 个修改的文件
包含
19 行增加
和
20 行删除
| @@ -12,6 +12,7 @@ namespace App\Console\Commands\AiBlog; | @@ -12,6 +12,7 @@ namespace App\Console\Commands\AiBlog; | ||
| 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\Project\ProjectAiSetting; | 14 | use App\Models\Project\ProjectAiSetting; |
| 15 | +use App\Models\RouteMap\RouteMap; | ||
| 15 | use App\Services\AiBlogService; | 16 | use App\Services\AiBlogService; |
| 16 | use App\Services\ProjectServer; | 17 | use App\Services\ProjectServer; |
| 17 | use Illuminate\Console\Command; | 18 | use Illuminate\Console\Command; |
| @@ -63,7 +64,17 @@ class AiBlogTask extends Command | @@ -63,7 +64,17 @@ class AiBlogTask extends Command | ||
| 63 | //保存当前项目ai_blog数据 | 64 | //保存当前项目ai_blog数据 |
| 64 | ProjectServer::useProject($info['project_id']); | 65 | ProjectServer::useProject($info['project_id']); |
| 65 | $aiBlogModel = new AiBlog(); | 66 | $aiBlogModel = new AiBlog(); |
| 66 | - $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'], 'status'=>2], ['task_id'=>$info['task_id']]); | 67 | + $aiBlogInfo = $aiBlogModel->read(['task_id'=>$info['task_id']],['id']); |
| 68 | + if($aiBlogInfo === false){ | ||
| 69 | + $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); | ||
| 70 | + continue; | ||
| 71 | + } | ||
| 72 | + //拿到返回的路由查看是否重复 | ||
| 73 | + $route = RouteMap::setRoute($result['data']['url'], RouteMap::SOURCE_AI_BLOG, $aiBlogInfo['id'], $this->user['project_id']); | ||
| 74 | + if($route != $result['data']['url']){ | ||
| 75 | + $aiBlogService->updateDetail(['route'=>$this->param['route']]); | ||
| 76 | + } | ||
| 77 | + $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'], 'route'=>$route ,'status'=>2], ['task_id'=>$info['task_id']]); | ||
| 67 | $this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']); | 78 | $this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']); |
| 68 | DB::disconnect('custom_mysql'); | 79 | DB::disconnect('custom_mysql'); |
| 69 | //修改任务状态 | 80 | //修改任务状态 |
| @@ -92,11 +92,9 @@ class AiBlogController extends BaseController | @@ -92,11 +92,9 @@ class AiBlogController extends BaseController | ||
| 92 | $this->request->validate([ | 92 | $this->request->validate([ |
| 93 | 'keyword'=>['required'], | 93 | 'keyword'=>['required'], |
| 94 | 'type'=>['required'], | 94 | 'type'=>['required'], |
| 95 | - 'route'=>['required'] | ||
| 96 | ],[ | 95 | ],[ |
| 97 | 'keyword.required' => '关键字不能为空', | 96 | 'keyword.required' => '关键字不能为空', |
| 98 | 'type.required' => '场景不能为空', | 97 | 'type.required' => '场景不能为空', |
| 99 | - 'route.required' => '路由不能为空', | ||
| 100 | ]); | 98 | ]); |
| 101 | //获取当前项目的ai_blog设置 | 99 | //获取当前项目的ai_blog设置 |
| 102 | $result = $aiBlogLogic->sendTask(); | 100 | $result = $aiBlogLogic->sendTask(); |
| @@ -135,8 +133,8 @@ class AiBlogController extends BaseController | @@ -135,8 +133,8 @@ class AiBlogController extends BaseController | ||
| 135 | } | 133 | } |
| 136 | 134 | ||
| 137 | /** | 135 | /** |
| 138 | - * @remark :获取详情数据 | ||
| 139 | - * @name :getAuthorInfo | 136 | + * @remark :编辑详情数据 |
| 137 | + * @name :saveBlogAuthor | ||
| 140 | * @author :lyh | 138 | * @author :lyh |
| 141 | * @method :post | 139 | * @method :post |
| 142 | * @time :2025/2/21 13:54 | 140 | * @time :2025/2/21 13:54 |
| @@ -38,9 +38,8 @@ class AiBlogLogic extends BaseLogic | @@ -38,9 +38,8 @@ class AiBlogLogic extends BaseLogic | ||
| 38 | $aiBlogService = new AiBlogService(); | 38 | $aiBlogService = new AiBlogService(); |
| 39 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 39 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 40 | $aiBlogService->key = $aiSettingInfo['key']; | 40 | $aiBlogService->key = $aiSettingInfo['key']; |
| 41 | - $aiBlogService->route = $this->param['route']; | ||
| 42 | $aiBlogService->author_id = $this->param['author_id']; | 41 | $aiBlogService->author_id = $this->param['author_id']; |
| 43 | - $aiBlogService->updateDetail($this->param['title'],$this->param['image']); | 42 | + $aiBlogService->updateDetail(['title'=>$this->param['title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); |
| 44 | }catch (\Exception $e){ | 43 | }catch (\Exception $e){ |
| 45 | $this->fail('保存失败,请联系管理员'); | 44 | $this->fail('保存失败,请联系管理员'); |
| 46 | } | 45 | } |
| @@ -101,10 +100,8 @@ class AiBlogLogic extends BaseLogic | @@ -101,10 +100,8 @@ class AiBlogLogic extends BaseLogic | ||
| 101 | $aiBlogTaskModel = new AiBlogTask(); | 100 | $aiBlogTaskModel = new AiBlogTask(); |
| 102 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]); | 101 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]); |
| 103 | $aiBlogModel = new AiBlog(); | 102 | $aiBlogModel = new AiBlog(); |
| 104 | - $aiBlogId = $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'], | 103 | + $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'], |
| 105 | ]); | 104 | ]); |
| 106 | - $route = RouteMap::setRoute($aiBlogService->route, RouteMap::SOURCE_AI_BLOG, $aiBlogId, $this->user['project_id']); | ||
| 107 | - $aiBlogModel->edit(['route'=>$route],['id'=>$aiBlogId]); | ||
| 108 | } | 105 | } |
| 109 | return $this->success(); | 106 | return $this->success(); |
| 110 | } | 107 | } |
| @@ -20,7 +20,6 @@ class AiBlogService | @@ -20,7 +20,6 @@ class AiBlogService | ||
| 20 | public $route = '';//回调地址 | 20 | public $route = '';//回调地址 |
| 21 | 21 | ||
| 22 | public $task_id = '';//任务id | 22 | public $task_id = '';//任务id |
| 23 | - | ||
| 24 | public $author_id = '';//作者id | 23 | public $author_id = '';//作者id |
| 25 | /** | 24 | /** |
| 26 | * @remark :创建项目 | 25 | * @remark :创建项目 |
| @@ -189,17 +188,11 @@ class AiBlogService | @@ -189,17 +188,11 @@ class AiBlogService | ||
| 189 | * @author :lyh | 188 | * @author :lyh |
| 190 | * @method :post | 189 | * @method :post |
| 191 | * @time :2025/2/21 14:38 | 190 | * @time :2025/2/21 14:38 |
| 191 | + * @param :title , thumb , route , task_id | ||
| 192 | */ | 192 | */ |
| 193 | - public function updateDetail($title,$image){ | 193 | + public function updateDetail($param){ |
| 194 | $request_url = $this->url.'api/result/save'; | 194 | $request_url = $this->url.'api/result/save'; |
| 195 | - $param = [ | ||
| 196 | - 'mch_id'=>$this->mch_id, | ||
| 197 | - 'author_id'=>$this->author_id, | ||
| 198 | - 'route'=>$this->route, | ||
| 199 | - 'author_id'=>$this->author_id, | ||
| 200 | - 'title'=>$title, | ||
| 201 | - 'thumb'=>$image, | ||
| 202 | - ]; | 195 | + $param['mch_id'] = $this->mch_id; |
| 203 | $this->sign = $this->generateSign($param,$this->key); | 196 | $this->sign = $this->generateSign($param,$this->key); |
| 204 | $param['sign'] = $this->sign; | 197 | $param['sign'] = $this->sign; |
| 205 | $result = http_post($request_url,json_encode($param,true)); | 198 | $result = http_post($request_url,json_encode($param,true)); |
-
请 注册 或 登录 后发表评论