/** * 管理员列表页面 */ public function actionIndex() { $this->setResponseData(['breads' => [['name' => Module::t('user.title')]]]); $status = $this->get('status', AdminUser::STATUS_OK); $userList = AdminUser::findAllArray(['status' => $status]); $roles = Role::findAllArray(['status' => Role::STATUS_OK]); $returnRoles = []; if ($roles) { foreach ($roles as $role) { $returnRoles[$role['id']] = $role['name']; } } $this->setResponseData('data', ['items' => $userList, 'roles' => $returnRoles, 'opt' => ['status' => $status], 'status' => [AdminUser::STATUS_OK => Module::t('status.ok'), AdminUser::STATUS_NO => Module::t('status.no')]]); }
/** * 删除角色 */ public function actionDelete() { $id = $this->get('id', 0); $role = Role::findeByCache($id); if ($role) { if ($role['id'] == 1) { $this->setError(Module::t('error.role.power.edit')); } else { Role::deleteAll(['id' => $id]); RolePermission::deleteAll(['role_id' => $id]); } } else { $this->setError(Module::t('error.role.notexists')); } }