作者 lyh

gx数据

... ... @@ -131,12 +131,18 @@ class AiBlogAuthorTask extends Command
if($info === false){
echo '执行新增'.PHP_EOL;
$id = $aiBlogAuthorModel->addReturnId($param);
$route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]);
$param['route'] = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit(['route'=>$param['route']],['id'=>$id]);
}else{
$param['route'] = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id);
$aiBlogAuthorModel->edit($param,['id'=>$info['id']]);
echo '执行更新'.PHP_EOL;
}
$aiSettingInfo = $this->getSetting();
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->updateAuthorInfo(['author_id'=>$param['author_id'],'route'=>$param['route'],'title'=>$param['title'],'picture'=>$param['image'],'description'=>$param['description']]);
}catch (\Exception $e){
echo 'error:'.$e->getMessage();
continue;
... ...
... ... @@ -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('保存失败,请联系管理员');
}
... ...