|
...
|
...
|
@@ -10,6 +10,7 @@ use App\Models\Project\AiBlogTask; |
|
|
|
use App\Models\Project\ProjectAiSetting;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Services\AiBlogService;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
class AiBlogLogic extends BaseLogic
|
|
|
|
{
|
|
...
|
...
|
@@ -28,11 +29,16 @@ class AiBlogLogic extends BaseLogic |
|
|
|
* @time :2025/2/21 14:51
|
|
|
|
*/
|
|
|
|
public function getProjectAiSetting(){
|
|
|
|
$ai_cache = Cache::get('ai_blog_'.$this->user['project_id']);
|
|
|
|
if($ai_cache){
|
|
|
|
return $ai_cache;
|
|
|
|
}
|
|
|
|
$projectAiSettingModel = new ProjectAiSetting();
|
|
|
|
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($aiSettingInfo === false){
|
|
|
|
$this->fail('请先联系管理员开启Ai博客');
|
|
|
|
}
|
|
|
|
Cache::put('ai_blog_'.$this->user['project_id'],$aiSettingInfo,3600);
|
|
|
|
return $aiSettingInfo;
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -76,8 +82,11 @@ class AiBlogLogic extends BaseLogic |
|
|
|
}
|
|
|
|
$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']]);
|
|
|
|
$aiSettingInfo = $this->getProjectAiSetting();
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'route'=>$this->param['route'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
...
|
...
|
|