From 0d8275657124ca8bf75541e78e25d48efe7fb2cd Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Wed, 18 Jun 2025 14:01:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E6=94=AF=E6=8C=81pid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugs/think-plugs-cms/src/controller/api/Category.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugs/think-plugs-cms/src/controller/api/Category.php b/plugs/think-plugs-cms/src/controller/api/Category.php index 2e937a9..f698e7a 100644 --- a/plugs/think-plugs-cms/src/controller/api/Category.php +++ b/plugs/think-plugs-cms/src/controller/api/Category.php @@ -8,7 +8,12 @@ use think\admin\Controller; class Category extends Controller { public function index() { - $categories = CmsCategory::mk()->where('status', 1)->order('sort asc,id desc')->field("id, name")->select(); + $pid = $this->request->get('pid'); + $query = CmsCategory::mk()->where('status', 1)->order('sort asc,id desc')->field("id, name"); + if ($pid > 0) { + $query->where('pid', $pid); + } + $categories = $query->select(); $this->success('获取分类成功', $categories); } } \ No newline at end of file