Skip to content
Clone
main
40 lines 1.3 KB Rust
use ::session::AuthedUser;
use api::http::{Path, State};
use api::rest::{AppResponseData, NoData};
use serde::Deserialize;
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
use crate::errors::ApiError;
use crate::services::service::SpaceService;
#[derive(Debug, Clone, Deserialize, IntoParams, ToSchema)]
pub struct MemberGroupPath {
pub space_name: String,
pub user_id: i64,
pub group_id: Uuid,
}
#[utoipa::path(
delete,
path = "/spaces/{space_name}/members/{user_id}/groups/{group_id}",
tag = "space",
description = "管理员移除成员的群组分配,未分配时幂等成功。",
params(MemberGroupPath),
responses(
(status = 200, description = "group unassigned", body = AppResponseData<NoData>),
(status = 403, description = "forbidden", body = AppResponseData<NoData>),
(status = 404, description = "not found", body = AppResponseData<NoData>),
(status = 401, description = "authentication required", body = AppResponseData<NoData>)
)
)]
pub async fn unassign_group(
State(service): State<SpaceService>,
AuthedUser(caller): AuthedUser,
Path(path): Path<MemberGroupPath>,
) -> Result<AppResponseData<NoData>, ApiError> {
service
.unassign_group(caller, &path.space_name, path.user_id, path.group_id)
.await?;
Ok(AppResponseData::empty())
}