/** * 列表 * * @param string $sort 排序 * @param int $page 页面 * @param int $limit 每页记录数 * @return array */ public function actionList($sort = '', $page = 1, $limit = 20) { $group_id = \Yii::$app->request->get('group_id'); $name = \Yii::$app->request->get('name'); $is_system = \Yii::$app->request->get('is_system'); $note = \Yii::$app->request->get('note'); $status = \Yii::$app->request->get('status'); $limit = intval($limit); $order = ExtHelpers::getOrder($sort, ['group_id', 'name', 'note', 'status'], [], 'group_id DESC'); $condition = '1'; $params = []; if ($group_id) { $condition .= ' and group_id=:group_id'; $params[':group_id'] = $group_id; } if ($name) { $condition .= ' and name like :name'; $params[':name'] = '%' . $name . '%'; } if (is_numeric($is_system)) { $condition .= ' and is_system=:is_system'; $params[':is_system'] = $is_system; } if ($note) { $condition .= ' and note like :note'; $params[':note'] = '%' . $note . '%'; } if (is_numeric($status)) { $condition .= ' and status=:status'; $params[':status'] = $status; } $data = DpAdminGroup::getListByCondition($condition, $params, $order, $page, $limit); return ['total' => $data['pagination']['totalCount'], 'list' => $data['list']]; }
/** * 列表 * * @param string $sort 排序 * @return array */ public function actionList($sort = '') { $order = ExtHelpers::getOrder($sort, ['url_id', 'route', 'method', 'host', 'enable_rule', 'note', 'status'], [], 'url_id DESC'); $list = []; $searchModel = new DpAdminMenuUrlSearch(); $dataProvider = $searchModel->search(\Yii::$app->request->get(), ''); $dataProvider->query->orderBy($order); $dataProvider->getPagination()->pageSizeParam = 'limit'; foreach ($dataProvider->getModels() as $itemModel) { /* @var $itemModel \wsl\rbac\models\DpAdminMenuUrl */ $list[] = $itemModel->getAttributes(); } return ['total' => $dataProvider->getTotalCount(), 'list' => $list]; }
/** * 列表 * * @param string $sort 排序 * @param int $page 页面 * @param int $limit 每页记录数 * @return array */ public function actionList($sort = '', $page = 1, $limit = 20) { $link_id = \Yii::$app->request->get('link_id'); $menu_id = \Yii::$app->request->get('menu_id'); $url_id = \Yii::$app->request->get('url_id'); $status = \Yii::$app->request->post('status'); $limit = intval($limit); $order = ExtHelpers::getOrder($sort, ['link_id', 'url_id'], [], 'link_id DESC'); $condition = '1'; $params = []; $tabName = DpAdminMenuUrlRelation::tableName(); $order = join(',', array_map(function ($value) use($tabName) { return $tabName . '.' . $value; }, explode(',', $order))); if ($link_id) { $condition .= ' and ' . $tabName . '.link_id=:link_id'; $params[':link_id'] = $link_id; } if ($menu_id) { $condition .= ' and ' . $tabName . '.menu_id=:menu_id'; $params[':menu_id'] = $menu_id; } if ($url_id) { $condition .= ' and ' . $tabName . '.url_id=:url_id'; $params[':url_id'] = $url_id; } if (is_numeric($status)) { $condition .= ' and ' . $tabName . '.status=:status'; $params[':status'] = $status; } $data = DpAdminMenuUrlRelation::getListByCondition($condition, $params, $order, $page, $limit); if ($data['list']) { foreach ($data['list'] as &$item) { foreach ($item['menuUrl'] as $k => $v) { $item['url.' . $k] = $v; } unset($item['menuUrl']); } } return ['total' => $data['pagination']['totalCount'], 'list' => $data['list']]; }
/** * 列表 * * @param string $sort 排序 * @param int $page 页码 * @param int $limit 每页记录数 * @return array */ public function actionList($sort = '', $page = 1, $limit = 20) { $user_id = \Yii::$app->request->get('user_id'); $username = \Yii::$app->request->get('username'); $nickname = \Yii::$app->request->get('nickname'); $group_ids = array_filter((array) \Yii::$app->request->get('group_ids')); $is_group_access = \Yii::$app->request->get('is_group_access'); $is_user_access = \Yii::$app->request->get('is_user_access'); $is_system = \Yii::$app->request->get('is_system'); $note = \Yii::$app->request->get('note'); $status = \Yii::$app->request->get('status'); $limit = intval($limit); $order = ExtHelpers::getOrder($sort, ['user_id', 'username', 'nickname', 'is_system', 'note', 'status'], [], 'user_id DESC'); $condition = '1'; $params = []; if ($user_id) { $condition .= ' and user_id=:user_id'; $params[':user_id'] = $user_id; } if ($username) { $condition .= ' and username=:username'; $params[':username'] = $username; } if (is_numeric($is_group_access)) { $condition .= ' and is_group_access=:is_group_access'; $params[':is_group_access'] = $is_group_access; } if (is_numeric($is_user_access)) { $condition .= ' and is_user_access=:is_user_access'; $params[':is_user_access'] = $is_user_access; } if (is_numeric($is_system)) { $condition .= ' and is_system=:is_system'; $params[':is_system'] = $is_system; } if ($note) { $condition .= ' and note like :note'; $params[':note'] = '%' . $note . '%'; } if ($nickname) { $condition .= ' and nickname like :nickname'; $params[':nickname'] = '%' . $nickname . '%'; } if ($group_ids && is_array($group_ids)) { $group_ids = array_filter($group_ids, function ($value) { return is_numeric($value); }); $condition .= ' and group_ids in (' . join(',', $group_ids) . ')'; } if (is_numeric($status)) { $condition .= ' and status=:status'; $params[':status'] = $status; } $condition .= ' and user_id!=1'; $data = DpAdminUser::getListByCondition($condition, $params, $order, $page, $limit); $list = []; if ($data['list']) { foreach ($data['list'] as $item) { $groupIds = StringHelper::explode($item['group_ids'], ',', true, true); asort($groupIds); $groupNames = []; foreach ($groupIds as $groupId) { $group = DpAdminGroup::getByGroupId($groupId); if ($group) { $groupNames[] = $group['name']; } } $list[] = ['user_id' => $item['user_id'], 'username' => $item['username'], 'nickname' => $item['nickname'], 'group_ids' => join(',', $groupIds), 'group_names' => join(',', $groupNames), 'is_group_access' => $item['is_group_access'], 'is_user_access' => $item['is_user_access'], 'is_system' => $item['is_system'], 'note' => $item['note'], 'status' => $item['status']]; } } return ['total' => $data['pagination']['totalCount'], 'list' => $list]; }
/** * 所有列表 * * @param string $sort 排序 * @return array */ public function actionAll($sort = '') { $order = ExtHelpers::getOrder($sort, ['menu_id', 'parent_id', 'text', 'title', 'url', 'view_package', 'expanded', 'closable', 'is_folder', 'is_open_url', 'is_open_target', 'is_every_open', 'is_hide', 'display_order', 'note', 'status'], [], 'menu_id DESC'); $list = DpAdminMenu::find()->orderBy($order)->all(); return ['total' => count($list), 'list' => $list]; }