From 319c545ae686fefa31582371f9d25c58f84e08fe Mon Sep 17 00:00:00 2001 From: chengxl0318 <1172937051@qq.com> Date: Fri, 28 Mar 2025 16:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82AI=E6=96=B0=E5=A2=9E=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=9C=89=E5=B0=B1=E8=BF=94=E5=9B=9E=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Aireview.php | 50 +++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/application/api/controller/Aireview.php b/application/api/controller/Aireview.php index f147d3b..4ff963e 100644 --- a/application/api/controller/Aireview.php +++ b/application/api/controller/Aireview.php @@ -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; + } }