From ed319689497e1735b40b5eb1575c44e32767e6b2 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 25 Apr 2023 16:25:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=88=86=E7=B1=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemMenus.php | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php b/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php index fe8348ea5..ee3956221 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php @@ -268,31 +268,28 @@ class SystemMenus extends AuthController return app('json')->success(['menus' => $menus, 'unique' => $unique]); } + /** + * 获取路由分类 + * @param SystemRouteCateServices $service + * @return \think\Response + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/4/25 + */ + public function ruleCate(SystemRouteCateServices $service) + { + return app('json')->success($service->getAllList('adminapi')); + } + /** * 获取接口列表 * @return array */ - public function ruleList() + public function ruleList(SystemRouteServices $services) { + $cateId = request()->get('cate_id', 0); //获取所有的路由 - $ruleList = app()->make(SystemRouteCateServices::class)->selectList(['app_name' => 'adminapi'], 'id,name', 0, 0, 'id asc,sort desc', ['children'])->toArray(); - $menuApiList = $this->services->getColumn(['auth_type' => 2, 'is_del' => 0], "concat(`api_url`,'_',lower(`methods`)) as rule"); - if ($menuApiList) $menuApiList = array_column($menuApiList, 'rule'); - $list = []; - foreach ($ruleList as $item) { - $children = []; - foreach ($item['children'] as $value) { - if ($value['type'] || !in_array($value['path'] . '_' . strtolower($value['method']), $menuApiList)) { - $value['real_name'] = $value['name'] ?? ''; - $value['method'] = strtoupper($value['method']); - $children[] = $value; - } - } - if ($children) { - $item['children'] = $children; - $list[] = $item; - } - } - return app('json')->success($list); + $ruleList = $services->selectList(['cate_id' => $cateId, 'app_name' => 'adminapi'])->toArray(); + return app('json')->success($ruleList); } }