作者 lyh

gx脚本导出产品

@@ -54,10 +54,12 @@ class AiBlogController extends BaseController @@ -54,10 +54,12 @@ class AiBlogController extends BaseController
54 public function sendTask(AiBlogLogic $aiBlogLogic){ 54 public function sendTask(AiBlogLogic $aiBlogLogic){
55 $this->request->validate([ 55 $this->request->validate([
56 'keyword'=>['required'], 56 'keyword'=>['required'],
57 - 'type'=>['required'] 57 + 'type'=>['required'],
  58 + 'route'=>['required']
58 ],[ 59 ],[
59 'keyword.required' => '关键字不能为空', 60 'keyword.required' => '关键字不能为空',
60 'type.required' => '场景不能为空', 61 'type.required' => '场景不能为空',
  62 + 'route.required' => '路由不能为空',
61 ]); 63 ]);
62 //获取当前项目的ai_blog设置 64 //获取当前项目的ai_blog设置
63 $result = $aiBlogLogic->sendTask(); 65 $result = $aiBlogLogic->sendTask();
@@ -55,9 +55,7 @@ class AiBlogLogic extends BaseLogic @@ -55,9 +55,7 @@ class AiBlogLogic extends BaseLogic
55 $aiBlogService = new AiBlogService(); 55 $aiBlogService = new AiBlogService();
56 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 56 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
57 $aiBlogService->key = $aiSettingInfo['key']; 57 $aiBlogService->key = $aiSettingInfo['key'];
58 - if(!empty($this->param['route'])){  
59 $aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en')); 58 $aiBlogService->route = generateRoute(Translate::tran($this->param['route'], 'en'));
60 - }  
61 $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); 59 $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
62 if($result['status'] == 200){ 60 if($result['status'] == 200){
63 $aiBlogTaskModel = new AiBlogTask(); 61 $aiBlogTaskModel = new AiBlogTask();
@@ -65,11 +63,9 @@ class AiBlogLogic extends BaseLogic @@ -65,11 +63,9 @@ class AiBlogLogic extends BaseLogic
65 $aiBlogModel = new AiBlog(); 63 $aiBlogModel = new AiBlog();
66 $aiBlogId = $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'], 64 $aiBlogId = $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],
67 ]); 65 ]);
68 - if(!empty($aiBlogService->route)){  
69 $route = RouteMap::setRoute($aiBlogService->route, RouteMap::SOURCE_AI_BLOG, $aiBlogId, $this->user['project_id']); 66 $route = RouteMap::setRoute($aiBlogService->route, RouteMap::SOURCE_AI_BLOG, $aiBlogId, $this->user['project_id']);
70 $aiBlogModel->edit(['route'=>$route],['id'=>$aiBlogId]); 67 $aiBlogModel->edit(['route'=>$route],['id'=>$aiBlogId]);
71 } 68 }
72 - }  
73 return $this->success(); 69 return $this->success();
74 } 70 }
75 } 71 }