From 1fb61f9eb6819b964670513670bdf84080728f2f Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 11 Apr 2023 16:47:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminapi/controller/v1/setting/SystemCrud.php | 14 ++++++++++++++ crmeb/app/adminapi/route/system.php | 2 ++ crmeb/app/dao/system/SystemMenusDao.php | 4 ++-- crmeb/app/services/system/SystemMenusServices.php | 4 ++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index 73dc0f142..b1b874a06 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -16,6 +16,7 @@ namespace app\adminapi\controller\v1\setting; use app\adminapi\controller\AuthController; use app\services\system\SystemCrudServices; +use app\services\system\SystemMenusServices; use think\facade\App; use think\helper\Str; @@ -110,6 +111,19 @@ class SystemCrud extends AuthController return app('json')->success($makePath); } + /** + * 获取tree菜单 + * @return \think\Response + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/4/11 + */ + public function getMenus() + { + return app('json')->success(app()->make(SystemMenusServices::class) + ->getList(['auth_type' => 1], ['pid', 'id', 'menu_name as label', 'id as value'])); + } + /** * 获取创建表数据类型 * @return \think\Response diff --git a/crmeb/app/adminapi/route/system.php b/crmeb/app/adminapi/route/system.php index ed08dc130..ccb3816c3 100644 --- a/crmeb/app/adminapi/route/system.php +++ b/crmeb/app/adminapi/route/system.php @@ -133,6 +133,8 @@ Route::group('system', function () { ]); //获取CRUD列表 Route::get('crud/column_type', 'v1.setting.SystemCrud/columnType')->option(['real_name' => '获取CRUD列表']); + //获取菜单TREE形数据 + Route::get('crud/menus', 'v1.setting.SystemCrud/getMenus')->option(['real_name' => '获取菜单TREE形数据']); //获取CRUD文件存放 Route::post('crud/file_path', 'v1.setting.SystemCrud/getFilePath')->option(['real_name' => '获取CRUD文件存放']); //删除CRUD diff --git a/crmeb/app/dao/system/SystemMenusDao.php b/crmeb/app/dao/system/SystemMenusDao.php index 276276604..a410beef4 100644 --- a/crmeb/app/dao/system/SystemMenusDao.php +++ b/crmeb/app/dao/system/SystemMenusDao.php @@ -76,10 +76,10 @@ class SystemMenusDao extends BaseDao * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function getMenusList(array $where) + public function getMenusList(array $where, array $field = ['*']) { $where = array_merge($where, ['is_del' => 0]); - return $this->search($where)->order('sort DESC,id ASC')->select(); + return $this->search($where)->field($field)->order('sort DESC,id ASC')->select(); } /** diff --git a/crmeb/app/services/system/SystemMenusServices.php b/crmeb/app/services/system/SystemMenusServices.php index c616fdaca..40f568eab 100644 --- a/crmeb/app/services/system/SystemMenusServices.php +++ b/crmeb/app/services/system/SystemMenusServices.php @@ -89,9 +89,9 @@ class SystemMenusServices extends BaseServices * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function getList(array $where) + public function getList(array $where, array $field = ['*']) { - $menusList = $this->dao->getMenusList($where); + $menusList = $this->dao->getMenusList($where, $field); $menusList = $this->getMenusData($menusList); return get_tree_children($menusList); }