|
...
|
...
|
@@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Ai; |
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Ai\AiBlog;
|
|
|
|
use App\Models\Ai\AiBlogAuthor;
|
|
|
|
use App\Models\Project\AiBlogTask;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\Project\ProjectAiSetting;
|
|
...
|
...
|
@@ -21,6 +22,22 @@ class AiBlogLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取配置信息
|
|
|
|
* @name :getProjectAiSetting
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/21 14:51
|
|
|
|
*/
|
|
|
|
public function getProjectAiSetting(){
|
|
|
|
$projectAiSettingModel = new ProjectAiSetting();
|
|
|
|
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($aiSettingInfo === false){
|
|
|
|
$this->fail('请先联系管理员开启Ai博客');
|
|
|
|
}
|
|
|
|
return $aiSettingInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :ai发布博客
|
|
|
|
* @name :blogSave
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -46,22 +63,6 @@ class AiBlogLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取配置信息
|
|
|
|
* @name :getProjectAiSetting
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/21 14:51
|
|
|
|
*/
|
|
|
|
public function getProjectAiSetting(){
|
|
|
|
$projectAiSettingModel = new ProjectAiSetting();
|
|
|
|
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($aiSettingInfo === false){
|
|
|
|
$this->fail('请先联系管理员开启Ai博客');
|
|
|
|
}
|
|
|
|
return $aiSettingInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑作者
|
|
|
|
* @name :saveAuthor
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -70,11 +71,14 @@ class AiBlogLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
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']);
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['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']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
...
|
...
|
@@ -87,6 +91,8 @@ class AiBlogLogic extends BaseLogic |
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/14 10:28
|
|
|
|
* @detail :type=2/生成文章 type=3/更新列表页记录
|
|
|
|
* @detail :status=1/待执行
|
|
|
|
*/
|
|
|
|
public function sendTask(){
|
|
|
|
$aiSettingInfo = $this->getProjectAiSetting();
|
|
...
|
...
|
@@ -97,31 +103,20 @@ class AiBlogLogic extends BaseLogic |
|
|
|
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
|
|
|
|
if($result['status'] == 200){
|
|
|
|
$aiBlogTaskModel = new AiBlogTask();
|
|
|
|
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]);
|
|
|
|
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]);
|
|
|
|
//增加一条更新列表页的记录
|
|
|
|
$aiThreeInfo = $aiBlogTaskModel->read(['project_id'=>$this->user['project_id'],'type'=>3,'status'=>1]);
|
|
|
|
if($aiThreeInfo === false){
|
|
|
|
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>3,'status'=>1]);
|
|
|
|
}
|
|
|
|
$aiBlogModel = new AiBlog();
|
|
|
|
$aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],
|
|
|
|
$aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :创建作者
|
|
|
|
* @name :createAuthor
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/20 10:46
|
|
|
|
*/
|
|
|
|
public function createAuthor(){
|
|
|
|
$aiSettingInfo = $this->getProjectAiSetting();
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$result = $aiBlogService->createAuthor();
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除
|
|
|
|
* @name :blogDelete
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -140,4 +135,5 @@ class AiBlogLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|