Skip to content
Clone
main
31 lines 1.1 KB Rust
use ::session::AuthedUser;
use api::http::{Path, State};
use api::rest::{AppResponseData, NoData};
use crate::errors::ApiError;
use crate::handlers::get_group::GroupPath;
use crate::services::service::SpaceService;
#[utoipa::path(
delete,
path = "/spaces/{space_name}/groups/{group_id}",
tag = "space",
description = "删除群组并清除成员分配和群组权限记录。",
params(GroupPath),
responses(
(status = 200, description = "group deleted", 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 delete_group(
State(service): State<SpaceService>,
AuthedUser(uid): AuthedUser,
Path(path): Path<GroupPath>,
) -> Result<AppResponseData<NoData>, ApiError> {
service
.delete_group(uid, &path.space_name, path.group_id)
.await?;
Ok(AppResponseData::empty())
}