redis调整
This commit is contained in:
@@ -80,7 +80,7 @@ class Article
|
|||||||
}
|
}
|
||||||
$iAiArticleId = $aAiArticle['ai_article_id'];
|
$iAiArticleId = $aAiArticle['ai_article_id'];
|
||||||
//必填参数验证
|
//必填参数验证
|
||||||
$aFields = ['article_id','article_type','media_type','journal_id','journal_issn','title_english','title_chinese','content','covered','discussion_results','research_method','digest','research_background','overview','summary','highlights','discussion','prospect','is_generate'];
|
$aFields = ['article_id','article_type','media_type','journal_id','journal_issn','title_english','title_chinese','covered','research_method','digest','research_background','overview','summary','conclusion','is_generate'];
|
||||||
$sFiled = '';
|
$sFiled = '';
|
||||||
$aUpdateParam = [];
|
$aUpdateParam = [];
|
||||||
foreach($aFields as $val){
|
foreach($aFields as $val){
|
||||||
@@ -90,7 +90,7 @@ class Article
|
|||||||
if(is_array($aParam[$val])){
|
if(is_array($aParam[$val])){
|
||||||
$aParam[$val] = implode(";",$aParam[$val]);
|
$aParam[$val] = implode(";",$aParam[$val]);
|
||||||
}
|
}
|
||||||
$aUpdateParam[$val] = empty($aParam[$val]) ? '' : addslashes($aParam[$val]);
|
$aUpdateParam[$val] = empty($aParam[$val]) ? '' : $this->func_safe($aParam[$val]);
|
||||||
}
|
}
|
||||||
if(empty($aUpdateParam)){
|
if(empty($aUpdateParam)){
|
||||||
return json_encode(['status' => 1,'msg' => 'No data currently being processed']);
|
return json_encode(['status' => 1,'msg' => 'No data currently being processed']);
|
||||||
@@ -101,7 +101,7 @@ class Article
|
|||||||
if($result === false){
|
if($result === false){
|
||||||
return json_encode(['status' => 4,'msg' => 'UPDATEING AI article failed']);
|
return json_encode(['status' => 4,'msg' => 'UPDATEING AI article failed']);
|
||||||
}
|
}
|
||||||
return json_encode(['status' => 1,'msg' => 'No data currently being processed']);
|
return json_encode(['status' => 1,'msg' => 'success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,9 +155,9 @@ class Article
|
|||||||
|
|
||||||
//获取文章领域
|
//获取文章领域
|
||||||
$aArticleField = $this->getArticleField($aWhere);
|
$aArticleField = $this->getArticleField($aWhere);
|
||||||
// if(!empty($aArticleField['data'])){
|
if(!empty($aArticleField['data'])){
|
||||||
// return json_encode(array('status' => 4,'msg' =>'The article has been added to the field' ));
|
return json_encode(array('status' => 4,'msg' =>'The article has been added to the field' ));
|
||||||
// }
|
}
|
||||||
//文章标题
|
//文章标题
|
||||||
$title = empty($aArticle['title']) ? '' : $aArticle['title'];
|
$title = empty($aArticle['title']) ? '' : $aArticle['title'];
|
||||||
if(empty($title)){
|
if(empty($title)){
|
||||||
@@ -329,4 +329,81 @@ class Article
|
|||||||
return ['status' => 1,'msg' => "Successfully added the article field"];
|
return ['status' => 1,'msg' => "Successfully added the article field"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新AI生成结果内容入库
|
||||||
|
* @param $messages 内容
|
||||||
|
* @param $model 模型类型
|
||||||
|
*/
|
||||||
|
public function updateAiArticleResults($aParam = []){
|
||||||
|
//文章ID
|
||||||
|
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||||
|
|
||||||
|
//二级标题ID
|
||||||
|
$iCurrentAmId = empty($aParam['current_am_id']) ? 0 : $aParam['current_am_id'];
|
||||||
|
//查询内容是否存在
|
||||||
|
if(empty($iArticleId) || empty($iCurrentAmId)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'Please select the article to be modified']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询投稿系统文章ID
|
||||||
|
$aWhere = ['w_article_id' => $iArticleId,'state' => ['in',[0,2]]];
|
||||||
|
$aProductionArticle = Db::name('production_article')->field('article_id')->where($aWhere)->find();
|
||||||
|
if(empty($aProductionArticle)){
|
||||||
|
return json_encode(['status' => 2,'msg' => 'The production article data is empty']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询文章是否生成内容
|
||||||
|
$aWhere = ['article_id' => $iArticleId,'current_am_id' => $iCurrentAmId];
|
||||||
|
$aAiArticleResults = Db::name('ai_article_results')->field('id')->where($aWhere)->find();
|
||||||
|
$iId = empty($aAiArticleResults['id']) ? 0 : $aAiArticleResults['id'];
|
||||||
|
//必填参数验证
|
||||||
|
$aFields = ['article_id','title','content','current_am_id','next_am_id','ami_id'];
|
||||||
|
$sFiled = '';
|
||||||
|
$aUpdateParam = [];
|
||||||
|
foreach($aFields as $val){
|
||||||
|
if(!isset($aParam[$val])){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(is_array($aParam[$val])){
|
||||||
|
$aParam[$val] = implode(";",$aParam[$val]);
|
||||||
|
}
|
||||||
|
$aUpdateParam[$val] = empty($aParam[$val]) ? '' : $this->func_safe($aParam[$val]);
|
||||||
|
}
|
||||||
|
if(empty($aUpdateParam)){
|
||||||
|
return json_encode(['status' => 1,'msg' => 'No data currently being processed']);
|
||||||
|
}
|
||||||
|
if(empty($iId)){
|
||||||
|
$aUpdateParam['create_time'] = time();
|
||||||
|
$result = Db::name('ai_article_results')->insert($aUpdateParam);
|
||||||
|
}else{
|
||||||
|
$aUpdateParam['update_time'] = time();
|
||||||
|
$result = Db::name('ai_article_results')->where('id',$iId)->limit(1)->update($aUpdateParam);
|
||||||
|
}
|
||||||
|
if($result === false){
|
||||||
|
return json_encode(['status' => 4,'msg' => 'UPDATEING AI article Results failed']);
|
||||||
|
}
|
||||||
|
return json_encode(['status' => 1,'msg' => 'success']);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 字符串过滤
|
||||||
|
* @param $messages 内容
|
||||||
|
* @param $model 模型类型
|
||||||
|
*/
|
||||||
|
private function func_safe($data,$ignore_magic_quotes=false){
|
||||||
|
if(is_string($data)){
|
||||||
|
$data=trim(htmlspecialchars($data));//防止被挂马,跨站攻击
|
||||||
|
if(($ignore_magic_quotes==true)||(!get_magic_quotes_gpc())){
|
||||||
|
$data = addslashes($data);//防止sql注入
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}else if(is_array($data)){//如果是数组采用递归过滤
|
||||||
|
foreach($data as $key=>$value){
|
||||||
|
$data[$key]=func_safe($value);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}else{
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user