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