/** * 更新一个权限 */ public function actionUpdateOnePermission() { try { $id = Yii::$app->request->post(PermissionModel::COL_ID); $name = Yii::$app->request->post(PermissionModel::COL_NAME); $routeIds = Yii::$app->request->post('route_ids'); PermissionModel::checkId($id); PermissionModel::checkName($name); PermissionAssignModel::checkRouteIds($routeIds); $result = PermissionModel::updateOnePermission($id, $name); if (!$result) { throw new JdbRbacException(); } $result = PermissionAssignModel::deleteBatchByPermissionId($id); if (!$result) { throw new JdbRbacException(); } $result = PermissionAssignModel::addBatch($id, $routeIds); return Utils::handlerForResult($result); } catch (JdbRbacException $e) { return Utils::handlerForException($e); } }