dao = new SystemRoleDao(); } /** * 列表 * @param array $param */ public function getList(array $param = []) { [$page,$limit] = $this->getPageValue(); $list = $this->dao->getList($this->searchFilter($param),'*',$page,$limit,'id desc'); $count = $this->dao->count($this->searchFilter($param)); return compact('list','count'); } protected function searchFilter(array $param = []): array { $filter = []; !empty($param['status']) && $filter[] = ["status", '=', $param['status']]; // !empty($param['is_del']) && $filter[] = ["is_del", '=', $param['is_del']]; return $filter; } /** * 获取添加身份规格 */ public function getMenus($roles = [], int $type = 1, int $is_show = 1): array { $field = ['title', 'pid', 'id']; // $where = ['is_del' => 0, 'type' => $type]; // if ($is_show) $where['sta'] = 1; $where = []; $menuService = new MenuService(); // if (!$roles) { $menus = $menuService->getMenusRoule($where, $field); // } else { // $roles = is_string($roles) ? explode(',', $roles) : $roles; // $ids = $this->dao->getRoleIds($roles); // $menus = $menuService->getMenusRoule(['rule' => $ids] + $where, $field); // } return $this->tidyMenuTier(false, $menus); } /** * 组合菜单数据 * @param bool $adminFilter * @param $menusList * @param int $pid * @param array $navList * @return array */ public function tidyMenuTier(bool $adminFilter = false, $menusList = [], int $pid = 0, array $navList = []): array { foreach ($menusList as $k => $menu) { $menu = $menu->getData(); if ($menu['pid'] == $pid) { unset($menusList[$k]); $menu['children'] = $this->tidyMenuTier($adminFilter, $menusList, $menu['id']); if ($pid == 0 && !count($menu['children'])) continue; if ($menu['children']) $menu['expand'] = true; $navList[] = $menu; } } return $navList; } }