请求AI新增判断有就返回没有请求
This commit is contained in:
@@ -91,12 +91,12 @@ class Aireview extends Base
|
||||
if(empty($aParam['article_id'])){
|
||||
exit(json_encode(array('status' => 2,'msg' => 'Please select an article' )));
|
||||
}
|
||||
if(empty($aParam['abstrart'])){
|
||||
exit(json_encode(array('status' => 2,'msg' => 'abstrart cannot be empty' )));
|
||||
}
|
||||
if(empty($aParam['keywords'])){
|
||||
exit(json_encode(array('status' => 2,'msg' => 'keywords cannot be empty' )));
|
||||
}
|
||||
// if(empty($aParam['abstrart'])){
|
||||
// exit(json_encode(array('status' => 2,'msg' => 'abstrart cannot be empty' )));
|
||||
// }
|
||||
// if(empty($aParam['keywords'])){
|
||||
// exit(json_encode(array('status' => 2,'msg' => 'keywords cannot be empty' )));
|
||||
// }
|
||||
|
||||
//查询文章
|
||||
$aArticle = Db::table('t_article')->field('article_id,abstrart,keywords,journal_id')->where('article_id',$aParam['article_id'])->find();
|
||||
@@ -104,6 +104,16 @@ class Aireview extends Base
|
||||
exit(json_encode(array('status' => 3,'msg' => 'No articles requiring review were found' )));
|
||||
}
|
||||
|
||||
//获取文章评测内容
|
||||
$aAiReview = Db::table('t_article_ai_review')->field('article_id,content')->where('article_id',$aParam['article_id'])->find();
|
||||
if(!empty($aAiReview)){
|
||||
exit(json_encode(array('status' => 1,'msg' => 'AI has been reviewed','data' => $aAiReview)));
|
||||
}
|
||||
|
||||
$aParam['abstrart'] = empty($aParam['abstrart']) ? $aArticle['abstrart'] : $aParam['abstrart'];//简介
|
||||
$aParam['keywords'] = empty($aParam['keywords']) ? $aArticle['keywords'] : $aParam['keywords'];//关键词
|
||||
|
||||
|
||||
//根据期刊ID查询期刊信息
|
||||
$aJournal = Db::table('t_journal')->field('zname')->where('journal_id',$aArticle['journal_id'])->find();
|
||||
if(empty($aJournal)){
|
||||
@@ -161,7 +171,7 @@ class Aireview extends Base
|
||||
protected function addAiReview($aParam = array()){
|
||||
|
||||
//返回数组
|
||||
$aResult = ['status' => 1,'msg' => 'AI review successful'];
|
||||
$aResult = ['status' => 1,'msg' => 'AI review successful','data' => $aParam];
|
||||
//必填参数验证
|
||||
$aFields = ['article_id','content'];
|
||||
$bStatus = true;
|
||||
@@ -204,4 +214,30 @@ class Aireview extends Base
|
||||
$aAiReview = Db::table('t_article_ai_review')->field('content')->where('article_id',$aParam['article_id'])->find();
|
||||
exit(json_encode(array('status' => 1,'msg' => 'Successfully obtained article review content','data' => $aAiReview)));
|
||||
}
|
||||
|
||||
public function test(){
|
||||
//获取参数
|
||||
$aParam = $this->request->post();
|
||||
if(empty($aParam['content'])){
|
||||
exit(json_encode(array('status' => 2,'msg' => '请输入需要验证的字符串' )));
|
||||
}
|
||||
if(!$this->checkMinChars($aParam['content'],200)){
|
||||
exit(json_encode(array('status' => 3,'msg' => '字符串长度未满足配置' )));
|
||||
}
|
||||
exit(json_encode(array('status' => 1,'msg' => '验证成功' )));
|
||||
}
|
||||
/**
|
||||
* 验证字符长度
|
||||
* @param $str 字符串
|
||||
* @param $num 字符长度
|
||||
* @return void
|
||||
*/
|
||||
private function checkMinChars($str = '',$num = 200) {
|
||||
// 过滤非汉字和英文的字符(保留汉字、大小写字母)
|
||||
$filteredStr = preg_replace('/[^\x{4e00}-\x{9fa5}a-zA-Z0-9]/u', '', $str);
|
||||
|
||||
// 计算有效字符总数(汉字按1个字符计,英文和数字同理)
|
||||
$total = mb_strlen($filteredStr, 'UTF-8');
|
||||
return $total >= $num;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user