Esempio n. 1
0
 /**
  * 更新一个角色
  */
 public function actionUpdateOneRole()
 {
     try {
         $roleId = Yii::$app->request->post(RoleModel::COL_ID);
         $name = Yii::$app->request->post(RoleModel::COL_NAME);
         $permissionIds = Yii::$app->request->post('permission_ids');
         RoleModel::checkId($roleId);
         RoleModel::checkName($name);
         RoleAssignModel::checkPermissionIds($permissionIds);
         $result = RoleModel::updateOneRole($roleId, $name);
         if (!$result) {
         }
         $result = RoleAssignModel::deleteAllByRoleId($roleId);
         if (!$result) {
         }
         $result = RoleAssignModel::addBatch($roleId, $permissionIds);
         return Utils::handlerForResult($result);
     } catch (JdbRbacException $e) {
         return Utils::handlerForException($e);
     }
 }