正在显示
1 个修改的文件
包含
9 行增加
和
6 行删除
| @@ -174,6 +174,7 @@ class AiBlogLogic extends BaseLogic | @@ -174,6 +174,7 @@ class AiBlogLogic extends BaseLogic | ||
| 174 | if(empty($param['route'])){ | 174 | if(empty($param['route'])){ |
| 175 | $param['route'] = generateRoute(Translate::tran($param['new_title'], 'en')); | 175 | $param['route'] = generateRoute(Translate::tran($param['new_title'], 'en')); |
| 176 | } | 176 | } |
| 177 | + //推送到ai的数据结构 | ||
| 177 | $data = [ | 178 | $data = [ |
| 178 | 'title'=>$param['new_title'], | 179 | 'title'=>$param['new_title'], |
| 179 | 'thumb'=>$param['image'], | 180 | 'thumb'=>$param['image'], |
| @@ -182,25 +183,27 @@ class AiBlogLogic extends BaseLogic | @@ -182,25 +183,27 @@ class AiBlogLogic extends BaseLogic | ||
| 182 | 'url'=>$param['route'], | 183 | 'url'=>$param['route'], |
| 183 | ]; | 184 | ]; |
| 184 | if(isset($param['id']) && !empty($param['id'])){ | 185 | if(isset($param['id']) && !empty($param['id'])){ |
| 186 | + $id = $param['id']; | ||
| 185 | $data['task_id'] = $param['task_id']; | 187 | $data['task_id'] = $param['task_id']; |
| 188 | + $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); | ||
| 186 | $this->model->edit($param,['id'=>$param['id']]); | 189 | $this->model->edit($param,['id'=>$param['id']]); |
| 187 | - $id = $param['id']; | ||
| 188 | }else{ | 190 | }else{ |
| 189 | $param['uuid'] = md5(date('YmdHis').rand(100,999).$this->user['project_id']); | 191 | $param['uuid'] = md5(date('YmdHis').rand(100,999).$this->user['project_id']); |
| 190 | $param['project_id'] = $this->user['project_id']; | 192 | $param['project_id'] = $this->user['project_id']; |
| 193 | + $param['status'] = $this->model::STATUS_RUNNING; | ||
| 191 | $id = $this->model->addReturnId($param); | 194 | $id = $this->model->addReturnId($param); |
| 195 | + $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); | ||
| 196 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 192 | } | 197 | } |
| 193 | - $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); | ||
| 194 | - $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 195 | }catch (\Exception $e){ | 198 | }catch (\Exception $e){ |
| 196 | $this->fail('保存失败,请联系管理员'); | 199 | $this->fail('保存失败,请联系管理员'); |
| 197 | } | 200 | } |
| 198 | $aiBlogService = new AiBlogService($this->user['project_id']); | 201 | $aiBlogService = new AiBlogService($this->user['project_id']); |
| 199 | $result = $aiBlogService->createCustomBlog($data); | 202 | $result = $aiBlogService->createCustomBlog($data); |
| 200 | - if($result['status'] == 200){ | ||
| 201 | - $this->model->edit(['task_id'=>$result['data']['task_id']],['id'=>$id]); | 203 | + if(isset($result['status']) && $result['status'] == 200){ |
| 204 | + $this->model->edit(['task_id'=>$result['data']['task_id'],'status'=>$this->model::STATUS_FINISH],['id'=>$id]); | ||
| 202 | //todo::更新列表页 | 205 | //todo::更新列表页 |
| 203 | - shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &"); | 206 | + shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &"); |
| 204 | } | 207 | } |
| 205 | return $this->success(); | 208 | return $this->success(); |
| 206 | } | 209 | } |
-
请 注册 或 登录 后发表评论