接口调整

This commit is contained in:
chengxl
2025-05-17 18:39:49 +08:00
parent 78932aadd2
commit 5b0ff03ab7

View File

@@ -219,7 +219,7 @@ class Aiarticle extends Base
} }
//查询AI内容是否生成 //查询AI内容是否生成
$aAiArticle = json_decode($this->getAiArticle($iArticleId),true); $aAiArticle = json_decode($this->getAiArticle(['article_id' => $iArticleId]),true);
$aAiArticleContent = empty($aAiArticle['data']) ? [] : $aAiArticle['data']; $aAiArticleContent = empty($aAiArticle['data']) ? [] : $aAiArticle['data'];
$aAiArticle = empty($aAiArticleContent['ai_article']) ? [] : $aAiArticleContent['ai_article']; $aAiArticle = empty($aAiArticleContent['ai_article']) ? [] : $aAiArticleContent['ai_article'];
@@ -251,34 +251,6 @@ class Aiarticle extends Base
*/ */
public function createForOpenAi($aArticleContent = [],$aAiArticle = []){ public function createForOpenAi($aArticleContent = [],$aAiArticle = []){
if(empty($aArticleContent)){
$aParam = $this->request->post();
$iId = empty($aParam['ai_article_id']) ? 0 : $aParam['ai_article_id'];
//查询AI内容是否生成
$aAiArticle = json_decode($this->getAiArticle(0,1,$iId),true);
$aAiArticleContent = empty($aAiArticle['data']) ? [] : $aAiArticle['data'];
$aAiArticle = empty($aAiArticleContent['ai_article']) ? [] : $aAiArticleContent['ai_article'];
if(empty($aAiArticle)){
return json_encode(['status' => 4,'msg' => 'The article has not been generated, please confirm']);
}
//判断是否生成
if($aAiArticle['is_generate'] == 1){
return json_encode(['status' => 5,'msg' => 'The data has been generated, please proceed with the next steps']);
}
$iArticleId = empty($aAiArticle['article_id']) ? '' : $aAiArticle['article_id'];
//获取文章是否生成AI内容
$aResult = json_decode($this->getArticle($iArticleId),true);
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
if($iStatus != 1){
return json_encode($aResult);
}
//获取数据
$aArticleContent = empty($aResult['data']) ? [] : $aResult['data'];
}
$iId = empty($aAiArticle['ai_article_id']) ? 0 : $aAiArticle['ai_article_id']; $iId = empty($aAiArticle['ai_article_id']) ? 0 : $aAiArticle['ai_article_id'];
@@ -387,20 +359,19 @@ class Aiarticle extends Base
/** /**
* 获取Ai生成文章信息 * 获取Ai生成文章信息
* @param article_id 文章ID * @param article_id 文章ID
* @param $iSelectAuthor 是否查询作者 1是2否
*/ */
public function getAiArticle($iArticleId = 0,$iSelectAuthor = 2,$iAiArticleId = 0){ public function getAiArticle($aParam = []){
$aParam = $this->request->post(); $aParam = empty($aParam) ? $this->request->post() : $aParam;
//文章ID //文章ID
$iArticleId = empty($iArticleId) ? '' : $iArticleId; $iArticleId = empty($aParam['article_id']) ? '' : $aParam['article_id'];
$iArticleIdParam = empty($aParam['article_id']) ? '' : $aParam['article_id'];
$iArticleId = empty($iArticleId) ? $iArticleIdParam : $iArticleId;
if(empty($iArticleId)){ if(empty($iArticleId)){
return json_encode(['status' => 2,'msg' => 'Please select the article to be generated']); return json_encode(['status' => 2,'msg' => 'Please select the article to be generated']);
} }
//是否查询作者 1是2否
$iSelectAuthor = empty($aParam['is_select_author']) ? 2 : $aParam['is_select_author'];
//查询AI生成的文章内容 //查询AI生成的文章内容
$aWhere = ['is_delete' => 2]; $aWhere = ['is_delete' => 2];
if(!empty($iArticleId)){ if(!empty($iArticleId)){
@@ -432,7 +403,14 @@ class Aiarticle extends Base
//查询是否上传到微信草稿箱 //查询是否上传到微信草稿箱
if(!empty($iArticleId)){ if(!empty($iArticleId)){
$aDraft = Db::name('ai_wechat_article')->where(['article_id' => $iArticleId,'is_delete' => 2])->column('template_id'); $aWhere = ['article_id' => $iArticleId,'is_delete' => 2];
if(!empty($aParam['template_id'])){
$aWhere['template_id'] = $aParam['template_id'];
}
if(!empty($aParam['wechat_id'])){
$aWhere['wechat_id'] = $aParam['wechat_id'];
}
$aDraft = Db::name('ai_wechat_article')->field('template_id,wechat_id')->where($aWhere)->select();
$aAiArticle['upload_draft'] = $aDraft; $aAiArticle['upload_draft'] = $aDraft;
} }
@@ -661,7 +639,7 @@ class Aiarticle extends Base
} }
//获取AI生成文章内容 //获取AI生成文章内容
$aAiContent = json_decode($this->getAiArticle($iArticleId,1),true); $aAiContent = json_decode($this->getAiArticle(['article_id' => $iArticleId,'is_select_author' => 1]),true);
$aAiContent = empty($aAiContent['data']) ? [] : $aAiContent['data']; $aAiContent = empty($aAiContent['data']) ? [] : $aAiContent['data'];
$aAiArticle = empty($aAiContent['ai_article']) ? [] : $aAiContent['ai_article']; $aAiArticle = empty($aAiContent['ai_article']) ? [] : $aAiContent['ai_article'];
//判断是否生成AI内容 //判断是否生成AI内容