|
...
|
...
|
@@ -160,4 +160,46 @@ class AiBlogLogic extends BaseLogic |
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存自定义
|
|
|
|
* @name :customSaveBlog
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/9/16 11:43
|
|
|
|
*/
|
|
|
|
public function customSaveBlog($param)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
//处理路由
|
|
|
|
if(empty($param['route'])){
|
|
|
|
$param['route'] = generateRoute(Translate::tran($param['new_title'], 'en'));
|
|
|
|
}
|
|
|
|
RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $param['id'], $this->user['project_id']);
|
|
|
|
$data = [
|
|
|
|
'title'=>$param['new_title'],
|
|
|
|
'thumb'=>$param['image'],
|
|
|
|
'foreword'=>$param['description'],
|
|
|
|
'author_id'=>$this->param['author_id'],
|
|
|
|
'url'=>$param['route'],
|
|
|
|
];
|
|
|
|
if(isset($param['id']) && !empty($param['id'])){
|
|
|
|
$data['task_id'] = $param['task_id'];
|
|
|
|
$this->model->edit($param,['id'=>$param['id']]);
|
|
|
|
$id = $param['id'];
|
|
|
|
}else{
|
|
|
|
$param['uuid'] = md5(date('YmdHis').rand(100,999).$this->user['project_id']);
|
|
|
|
$id = $this->model->addReturnId($param);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
$aiBlogService = new AiBlogService($this->user['project_id']);
|
|
|
|
$result = $aiBlogService->createCustomBlog($data);
|
|
|
|
if($result['status'] == 200){
|
|
|
|
$this->model->edit(['task_id'=>$result['data']['task_id']],['id'=>$id]);
|
|
|
|
}
|
|
|
|
//todo::更新列表页
|
|
|
|
// shell_exec("php artisan save_ai_blog_list {$this->user['project_id']} > /dev/null 2>&1 &");
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|