|
...
|
...
|
@@ -13,6 +13,7 @@ use App\Models\Ai\AiLog; |
|
|
|
use App\Models\Project\DeployOptimize;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\Project\ProjectKeyword;
|
|
|
|
use App\Services\AiCommandService;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
class AiCommandController extends BaseController
|
|
...
|
...
|
@@ -79,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);
|
|
|
|
}
|
|
...
|
...
|
@@ -95,22 +96,48 @@ 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]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据指令获取内容
|
|
|
|
* @name :sendLayoutDesign
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/5/26 17:39
|
|
|
|
*/
|
|
|
|
public function sendLayoutDesign(){
|
|
|
|
$this->request->validate([
|
|
|
|
'html'=>['required']
|
|
|
|
],[
|
|
|
|
'html.required' => 'html不能为空',
|
|
|
|
]);
|
|
|
|
$aiCommonModel = new AiCommand();
|
|
|
|
$info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['ai']);
|
|
|
|
if($info === false){
|
|
|
|
$info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['ai']);
|
|
|
|
}
|
|
|
|
$aiCommandService = new AiCommandService();
|
|
|
|
$ai = str_replace('{html}',$this->param['html'],$info['ai']);
|
|
|
|
$result = $aiCommandService->send_layout_design($ai);
|
|
|
|
$this->response('success', Code::SUCCESS, $result);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|