作者 lyh

变更数据

@@ -214,4 +214,32 @@ class AiBlogController extends BaseController @@ -214,4 +214,32 @@ class AiBlogController extends BaseController
214 $info['image'] = getImageUrl($info['image']); 214 $info['image'] = getImageUrl($info['image']);
215 $this->response('success',Code::SUCCESS,$info); 215 $this->response('success',Code::SUCCESS,$info);
216 } 216 }
  217 +
  218 + /**
  219 + * @remark :保存自定义Blog
  220 + * @name :customSaveBlog
  221 + * @author :lyh
  222 + * @method :post
  223 + * @time :2025/9/16 10:43
  224 + */
  225 + public function customSaveBlog(AiBlogLogic $aiBlogLogic)
  226 + {
  227 + $this->request->validate([
  228 + 'new_title'=>['required'],
  229 + 'image'=>['required'],
  230 + 'author_id'=>['required'],
  231 + 'text'=>['required'],
  232 + 'description'=>['required'],
  233 + 'route'=>['required'],
  234 + ],[
  235 + 'new_title.required' => '标题不能为空',
  236 + 'image.required' => '缩略图不能为空',
  237 + 'author_id.required' => '作者id不能为空',
  238 + 'text.required' => '作者id不能为空',
  239 + 'description.required' => '短描述不能为空',
  240 + 'route.required' => '路由不能为空',
  241 + ]);
  242 + $data = $aiBlogLogic->customSaveBlog($this->param);
  243 + $this->response('success',Code::SUCCESS,$data);
  244 + }
217 } 245 }
@@ -178,7 +178,6 @@ class InquiryController extends BaseController @@ -178,7 +178,6 @@ class InquiryController extends BaseController
178 ],[ 178 ],[
179 'id.required' => 'ID不能为空' 179 'id.required' => 'ID不能为空'
180 ]); 180 ]);
181 -  
182 if(!empty($this->param['form_id'])){ 181 if(!empty($this->param['form_id'])){
183 $data = $logic->getFormDataInfo($this->param['id'], $this->param['form_id']); 182 $data = $logic->getFormDataInfo($this->param['id'], $this->param['form_id']);
184 }elseif(($this->param['type']??'') == 'other'){ 183 }elseif(($this->param['type']??'') == 'other'){
@@ -160,4 +160,42 @@ class AiBlogLogic extends BaseLogic @@ -160,4 +160,42 @@ class AiBlogLogic extends BaseLogic
160 return $this->success(); 160 return $this->success();
161 } 161 }
162 162
  163 + /**
  164 + * @remark :保存自定义
  165 + * @name :customSaveBlog
  166 + * @author :lyh
  167 + * @method :post
  168 + * @time :2025/9/16 11:43
  169 + */
  170 + public function customSaveBlog($param)
  171 + {
  172 + try {
  173 + //处理路由
  174 + if(empty($param['route'])){
  175 + $param['route'] = generateRoute(Translate::tran($param['new_title'], 'en'));
  176 + }
  177 + RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $param['id'], $this->user['project_id']);
  178 + $data = [
  179 + 'title'=>$param['new_title'],
  180 + 'thumb'=>$param['image'],
  181 + 'foreword'=>$param['description'],
  182 + 'author_id'=>$this->param['author_id'],
  183 + 'url'=>$param['route'],
  184 + ];
  185 + if(isset($param['id']) && !empty($param['id'])){
  186 + $data['task_id'] = $param['task_id'];
  187 + $this->model->edit($param,['id'=>$param['id']]);
  188 + }else{
  189 + $param['uuid'] = md5(date('YmdHis').rand(100,999).$this->user['project_id']);
  190 + $this->model->addReturnId($param);
  191 + }
  192 + $aiBlogService = new AiBlogService($this->user['project_id']);
  193 + $aiBlogService->createCustomBlog($data);
  194 + }catch (\Exception $e){
  195 + $this->fail('保存失败,请联系管理员');
  196 + }
  197 + //todo::更新列表页
  198 +// shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &");
  199 + return $this->success();
  200 + }
163 } 201 }
@@ -270,4 +270,21 @@ class AiBlogService @@ -270,4 +270,21 @@ class AiBlogService
270 $result = http_post($request_url,json_encode($param,true)); 270 $result = http_post($request_url,json_encode($param,true));
271 return $result; 271 return $result;
272 } 272 }
  273 +
  274 + /**
  275 + * @remark :自定义博客
  276 + * @name :createCustomBlog
  277 + * @author :lyh
  278 + * @method :post
  279 + * @time :2025/9/16 13:41
  280 + */
  281 + public function createCustomBlog($param)
  282 + {
  283 + $request_url = $this->url.'api/result/save_customer_article';
  284 + $param['mch_id'] = $this->mch_id;
  285 + $this->sign = $this->generateSign($param,$this->key);
  286 + $param['sign'] = $this->sign;
  287 + $result = http_post($request_url,json_encode($param,true));
  288 + return $result;
  289 + }
273 } 290 }