作者 lyh

gx脚本

... ... @@ -80,9 +80,9 @@ class AiCommandController extends BaseController
*/
public function getLayoutDesignInfo(){
$aiCommonModel = new AiCommand();
$data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']]);
$data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['key','ai']);
if($data === false){
$data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0]);
$data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['key','ai']);
}
$this->response('success', Code::SUCCESS, $data);
}
... ... @@ -96,21 +96,23 @@ class AiCommandController extends BaseController
*/
public function saveLayoutDesign(){
$this->request->validate([
'key'=>['required']
'ai'=>['required'],
],[
'key.required' => '场景不能为空',
'ai.required' => '指令不能为空',
]);
$aiCommonModel = new AiCommand();
if($this->param['key'] != 'ai_layout_design'){
$this->response('success');
$this->response('非法key',Code::USER_ERROR);
}
$data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']]);
$data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['id']);
if($data === false) {
$this->param['project_id'] = $this->user['project_id'];
$id = $aiCommonModel->addReturnId($this->param);
$param = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['name','key']);
$param['project_id'] = $this->user['project_id'];
$param['ai'] = $this->param['ai'];
$id = $aiCommonModel->addReturnId($param);
}else{
$id = $data['id'];
$aiCommonModel->edit($this->param,['id'=>$data['id']]);
$aiCommonModel->edit(['ai'=>$this->param['ai']],['id'=>$data['id']]);
}
$this->response('success', Code::SUCCESS, ['id'=>$id]);
}
... ... @@ -124,10 +126,8 @@ class AiCommandController extends BaseController
*/
public function sendLayoutDesign(){
$this->request->validate([
'key'=>['required'],
'html'=>['required']
],[
'key.required' => '场景不能为空',
'html.required' => 'html不能为空',
]);
$aiCommonModel = new AiCommand();
... ...