|
@@ -13,6 +13,7 @@ use App\Models\Ai\AiLog; |
|
@@ -13,6 +13,7 @@ use App\Models\Ai\AiLog; |
|
13
|
use App\Models\Project\DeployOptimize;
|
13
|
use App\Models\Project\DeployOptimize;
|
|
14
|
use App\Models\Project\Project;
|
14
|
use App\Models\Project\Project;
|
|
15
|
use App\Models\Project\ProjectKeyword;
|
15
|
use App\Models\Project\ProjectKeyword;
|
|
|
|
16
|
+use App\Services\AiCommandService;
|
|
16
|
use Illuminate\Support\Facades\Cache;
|
17
|
use Illuminate\Support\Facades\Cache;
|
|
17
|
|
18
|
|
|
18
|
class AiCommandController extends BaseController
|
19
|
class AiCommandController extends BaseController
|
|
@@ -79,9 +80,9 @@ class AiCommandController extends BaseController |
|
@@ -79,9 +80,9 @@ class AiCommandController extends BaseController |
|
79
|
*/
|
80
|
*/
|
|
80
|
public function getLayoutDesignInfo(){
|
81
|
public function getLayoutDesignInfo(){
|
|
81
|
$aiCommonModel = new AiCommand();
|
82
|
$aiCommonModel = new AiCommand();
|
|
82
|
- $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']]);
|
83
|
+ $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['key','ai']);
|
|
83
|
if($data === false){
|
84
|
if($data === false){
|
|
84
|
- $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0]);
|
85
|
+ $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['key','ai']);
|
|
85
|
}
|
86
|
}
|
|
86
|
$this->response('success', Code::SUCCESS, $data);
|
87
|
$this->response('success', Code::SUCCESS, $data);
|
|
87
|
}
|
88
|
}
|
|
@@ -95,22 +96,48 @@ class AiCommandController extends BaseController |
|
@@ -95,22 +96,48 @@ class AiCommandController extends BaseController |
|
95
|
*/
|
96
|
*/
|
|
96
|
public function saveLayoutDesign(){
|
97
|
public function saveLayoutDesign(){
|
|
97
|
$this->request->validate([
|
98
|
$this->request->validate([
|
|
98
|
- 'key'=>['required']
|
99
|
+ 'ai'=>['required'],
|
|
99
|
],[
|
100
|
],[
|
|
100
|
- 'key.required' => '场景不能为空',
|
101
|
+ 'ai.required' => '指令不能为空',
|
|
101
|
]);
|
102
|
]);
|
|
102
|
$aiCommonModel = new AiCommand();
|
103
|
$aiCommonModel = new AiCommand();
|
|
103
|
if($this->param['key'] != 'ai_layout_design'){
|
104
|
if($this->param['key'] != 'ai_layout_design'){
|
|
104
|
- $this->response('success');
|
105
|
+ $this->response('非法key',Code::USER_ERROR);
|
|
105
|
}
|
106
|
}
|
|
106
|
- $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']]);
|
107
|
+ $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['id']);
|
|
107
|
if($data === false) {
|
108
|
if($data === false) {
|
|
108
|
- $this->param['project_id'] = $this->user['project_id'];
|
|
|
|
109
|
- $id = $aiCommonModel->addReturnId($this->param);
|
109
|
+ $param = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['name','key']);
|
|
|
|
110
|
+ $param['project_id'] = $this->user['project_id'];
|
|
|
|
111
|
+ $param['ai'] = $this->param['ai'];
|
|
|
|
112
|
+ $id = $aiCommonModel->addReturnId($param);
|
|
110
|
}else{
|
113
|
}else{
|
|
111
|
$id = $data['id'];
|
114
|
$id = $data['id'];
|
|
112
|
- $aiCommonModel->edit($this->param,['id'=>$data['id']]);
|
115
|
+ $aiCommonModel->edit(['ai'=>$this->param['ai']],['id'=>$data['id']]);
|
|
113
|
}
|
116
|
}
|
|
114
|
$this->response('success', Code::SUCCESS, ['id'=>$id]);
|
117
|
$this->response('success', Code::SUCCESS, ['id'=>$id]);
|
|
115
|
}
|
118
|
}
|
|
|
|
119
|
+
|
|
|
|
120
|
+ /**
|
|
|
|
121
|
+ * @remark :根据指令获取内容
|
|
|
|
122
|
+ * @name :sendLayoutDesign
|
|
|
|
123
|
+ * @author :lyh
|
|
|
|
124
|
+ * @method :post
|
|
|
|
125
|
+ * @time :2025/5/26 17:39
|
|
|
|
126
|
+ */
|
|
|
|
127
|
+ public function sendLayoutDesign(){
|
|
|
|
128
|
+ $this->request->validate([
|
|
|
|
129
|
+ 'html'=>['required']
|
|
|
|
130
|
+ ],[
|
|
|
|
131
|
+ 'html.required' => 'html不能为空',
|
|
|
|
132
|
+ ]);
|
|
|
|
133
|
+ $aiCommonModel = new AiCommand();
|
|
|
|
134
|
+ $info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['ai']);
|
|
|
|
135
|
+ if($info === false){
|
|
|
|
136
|
+ $info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['ai']);
|
|
|
|
137
|
+ }
|
|
|
|
138
|
+ $aiCommandService = new AiCommandService();
|
|
|
|
139
|
+ $ai = str_replace('{html}',$this->param['html'],$info['ai']);
|
|
|
|
140
|
+ $result = $aiCommandService->send_layout_design($ai);
|
|
|
|
141
|
+ $this->response('success', Code::SUCCESS, $result);
|
|
|
|
142
|
+ }
|
|
116
|
} |
143
|
} |