From f694881bb5853c7e3295680c413c078cbb5def0d Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Wed, 11 Jun 2025 11:38:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20nas=E5=B8=AE=E5=8A=A9=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/TopicNas.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index 0ba369eb..70e15097 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -269,6 +269,25 @@ class TopicNas extends Common { $keywords = request()->post('keywords'); // 根据关键词查询文章 + $parent = ArticleCategoryModel::uniqueLabel('CATEGORY_681182e0a4529') + ->language($this->lang_id) + ->value('id'); + + // 获取帮且中心分类子分类 + $table_name = (new ArticleCategoryModel)->getTable(); + $categorys = \think\facade\Db::query(preg_replace( + '/\s+/u', + ' ', + "WITH RECURSIVE article_tree_by AS ( + SELECT a.id, a.pid FROM $table_name a WHERE a.id = {$parent} + UNION ALL + SELECT k.id, k.pid FROM $table_name k INNER JOIN article_tree_by t ON t.id = k.pid + ) + SELECT id FROM article_tree_by WHERE id <> {$parent}" + )); + if (empty($categorys)) return success('success', []); + + // 获取文章数据 $articles = ArticleModel::field([ 'id', 'title' @@ -277,6 +296,7 @@ class TopicNas extends Common 'title' => $keywords??null ]) ->language($this->lang_id) + ->where('category_id', 'IN', array_column($categorys, 'id')) ->select(); return success('success', $articles->toArray());