From 0745837beb64cd53cf4bd619f07ac7f78918b95d Mon Sep 17 00:00:00 2001 From: "zhangf@suq.cn" Date: Thu, 11 Dec 2025 10:38:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(article):=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=88=86=E7=B1=BBID=E7=AD=9B=E9=80=89=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在控制器中增加 article_category_id 参数支持 - 在服务层实现根据 article_category_id 筛选逻辑 - 优化查询条件构建,确保参数安全过滤 --- app/controller/CreationArticleController.php | 1 + app/service/CreationArticleService.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/controller/CreationArticleController.php b/app/controller/CreationArticleController.php index 38e1a63..cf85bfb 100644 --- a/app/controller/CreationArticleController.php +++ b/app/controller/CreationArticleController.php @@ -38,6 +38,7 @@ class CreationArticleController public function index(CreationArticleService $service): Response { $params = requestOnly([ + 'article_category_id' => '', 'article_category' => '', 'task' => '', 'title' => '', diff --git a/app/service/CreationArticleService.php b/app/service/CreationArticleService.php index 303126d..2c8b3f5 100644 --- a/app/service/CreationArticleService.php +++ b/app/service/CreationArticleService.php @@ -70,6 +70,9 @@ class CreationArticleService extends BaseService $query = [ 'delete_time' => 0 ]; + if (isNotBlank($params['article_category_id'])) { + $query[] = ['article_category_id', '=', $params['article_category_id']]; + } if (isNotBlank($params['article_category'])) { $cids = $this->articleCategoryDao->getColumn([['name', 'like', '%' . $params['article_category'] . '%']], 'id'); $query[] = ['article_category_id', 'in', $cids];