From 0aa18858c8d83cd6117b903e4877b1b32dcb2f59 Mon Sep 17 00:00:00 2001 From: chengxl0318 <1172937051@qq.com> Date: Fri, 28 Mar 2025 14:59:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E7=AB=A0=E6=91=98?= =?UTF-8?q?=E8=A6=81=E5=8A=A0=E5=AD=97=E6=95=B0=E6=9C=80=E4=BD=8E=E9=99=90?= =?UTF-8?q?=E5=88=B6200=EF=BC=8C=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5ai=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Article.php | 40 +++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index b125bfa..140715d 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -106,6 +106,13 @@ class Article extends Base ->limit($limit_start, $data['pageSize'])->select(); $count = $this->article_obj->where($where)->count(); + //查询AI审核内容 chengxiaoling 20250328 start + $aAiReview = array(); + if(!empty($res)){ + $aArticleId = array_column($res, 'article_id'); + $aAiReview = Db::table('t_article_ai_review')->field('article_id,content')->whereIn('article_id',$aArticleId)->column('article_id,content'); + } + //查询AI审核内容 chengxiaoling 20250328 end foreach ($res as $key => $val) { //查询建议转投详情 @@ -131,6 +138,10 @@ class Article extends Base } } $res[$key]['proof'] = $proof_state; + + //返回AI审核内容 chengxiaoling 20250328 start + $res[$key]['ai_review'] = empty($aAiReview[$val['article_id']]) ? '' : $aAiReview[$val['article_id']]; + //返回AI审核内容 chengxiaoling 20250328 end } //返回数据 @@ -613,6 +624,13 @@ class Article extends Base $user_res = $this->user_obj->where(['account' => $username])->find(); $article_old_info = $this->article_obj->where('article_id', $data['articleId'])->find(); + + //判断简介字符串长度是否不低于200 chengxiaoling 20250327 start + if(!$this->checkMinChars($data['abstrart'],200)){ + return jsonError("The abstract should not be less than 200 Chinese characters or English words!"); + } + //判断简介字符串长度是否不低于200 chengxiaoling 20250327 end + Db::startTrans(); //更新文章信息 @@ -2482,7 +2500,6 @@ class Article extends Base //接受参数,查询信息 $data = $this->request->post(); - $user_res = $this->user_obj->where('account', $data['username'])->find(); //确定用户是否属于黑名单 @@ -2916,6 +2933,12 @@ class Article extends Base if (!$rule->check($data)) { return jsonError($rule->getError()); } + //判断简介字符串长度是否不低于200 chengxiaoling 20250327 start + if(!$this->checkMinChars($data['abstrart'],200)){ + return jsonError("The abstract should not be less than 200 Chinese characters or English words!"); + } + //判断简介字符串长度是否不低于200 chengxiaoling 20250327 end + $user_info = $this->user_obj->where('user_id', $data['user_id'])->find(); $journal_info = $this->journal_obj->where('journal_id', $data['journal'])->find(); @@ -4254,4 +4277,19 @@ class Article extends Base $this->user_msg_obj->where("user_id", $data['editor_id'])->update(["state" => 1]); return jsonSuccess([]); } + + /** + * 验证字符长度 + * @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; + } }