|
...
|
...
|
@@ -50,41 +50,18 @@ class AiVideoLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/5 14:46
|
|
|
|
*/
|
|
|
|
public function blogSave(){
|
|
|
|
public function videoSave(){
|
|
|
|
try {
|
|
|
|
if(!empty($this->param['image'])){
|
|
|
|
$this->param['image'] = str_replace_url($this->param['image']);
|
|
|
|
}
|
|
|
|
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']);
|
|
|
|
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_VIDEO, $this->param['id'], $this->user['project_id']);
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$aiSettingInfo = $this->getProjectAiSetting();
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->updateDetail(['title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑作者
|
|
|
|
* @name :saveAuthor
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/21 14:46
|
|
|
|
*/
|
|
|
|
public function saveBlogAuthor(){
|
|
|
|
try {
|
|
|
|
$aiAuthorModel = new AiBlogAuthor();
|
|
|
|
if(!empty($this->param['image'])){
|
|
|
|
$this->param['image'] = str_replace_url($this->param['image']);
|
|
|
|
}
|
|
|
|
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']);
|
|
|
|
$aiAuthorModel->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
|
|
|
|
$aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
...
|
...
|
@@ -97,7 +74,7 @@ class AiVideoLogic extends BaseLogic |
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/14 10:28
|
|
|
|
* @detail :type=2/生成文章 type=3/更新列表页记录
|
|
|
|
* @detail :createTask =>type=2/生成文章
|
|
|
|
* @detail :status=1/待执行
|
|
|
|
*/
|
|
|
|
public function sendTask(){
|
|
...
|
...
|
@@ -106,23 +83,23 @@ class AiVideoLogic extends BaseLogic |
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
|
|
|
|
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type'],'video');
|
|
|
|
$result = $aiBlogService->createTask($this->param['keyword'],2,'video',$this->param['anchor'] ?? []);
|
|
|
|
if($result['status'] == 200){
|
|
|
|
$aiBlogTaskModel = new AiBlogTask();
|
|
|
|
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>3,'task_id'=>$result['data']['task_id'],'status'=>1]);
|
|
|
|
$this->model->addReturnId(['keyword'=>$this->param['keyword'],'status'=>1,'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
$this->model->addReturnId(['keyword'=>$this->param['keyword'],'status'=>1,'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true)]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除
|
|
|
|
* @name :blogDelete
|
|
|
|
* @remark :删除aiVideo
|
|
|
|
* @name :videoDelete
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/20 18:21
|
|
|
|
* @time :2025/3/6 10:00
|
|
|
|
*/
|
|
|
|
public function blogDelete(){
|
|
|
|
public function videoDelete(){
|
|
|
|
try {
|
|
|
|
$aiSettingInfo = $this->getProjectAiSetting();
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
...
|
...
|
@@ -132,12 +109,11 @@ class AiVideoLogic extends BaseLogic |
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->delDetail($info['task_id']);
|
|
|
|
//删除路由映射
|
|
|
|
RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']);
|
|
|
|
RouteMap::delRoute(RouteMap::SOURCE_AI_VIDEO, $id, $this->user['project_id']);
|
|
|
|
$this->model->del(['id'=>$id]);
|
|
|
|
}
|
|
|
|
shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &');
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('删除失败');
|
|
|
|
$this->fail('删除失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
...
|
...
|
|