request->adminInfo(); [$menus, $uniqueAuth] = $services->getMenusList($adminInfo['roles'], (int)$adminInfo['level']); return $this->success([ 'menus' => $menus, 'unique_auth' => $uniqueAuth, 'role' => $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles'], 1, 0), 'user_info' => [ 'id' => $adminInfo['id'], 'account' => $adminInfo['account'], 'phone' => $adminInfo['phone'], 'real_name' => $adminInfo['real_name'], 'head_pic' => $adminInfo['head_pic'], 'roles' => $roleServices->getRolesNames($adminInfo['roles']) ] ]); } /** * 格式化菜单 * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException|InvalidArgumentException */ public function menusList() { $cahcheKey = md5('admin_common_menu_list'); $list = CacheService::redisHandler()->get($cahcheKey); if (!$list) { /** @var SystemMenusServices $menusServices */ $menusServices = app()->make(SystemMenusServices::class); $menus = $menusServices->search(['is_show' => 1, 'auth_type' => 1, 'is_show_path' => 0])->where('type', 1) ->field('id,pid,menu_name,menu_path,unique_auth,sort')->order('sort DESC')->select(); $counts = $menusServices->getColumn([ ['is_show', '=', 1], ['auth_type', '=', 1], ['is_show_path', '=', 0], ], 'pid'); $data = []; foreach ($menus as $key => $item) { $pid = $item->getData('pid'); $data[$key] = json_decode($item, true); $data[$key]['pid'] = $pid; if (in_array($item->id, $counts)) { $data[$key]['type'] = 1; } else { $data[$key]['type'] = 0; } $data[$key]['menu_path'] = preg_replace('/^\/admin/', '', $item['menu_path']); } $list = sort_list_tier($data); CacheService::redisHandler()->set($cahcheKey, $list, 86400); } return app('json')->success($list); } /** * @param CityAreaServices $services * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function city(CityAreaServices $services) { $pid = $this->request->get('pid', 0); $type = $this->request->get('type', 0); return $this->success($services->getCityTreeList((int)$pid, $type)); } }