use ::session::AuthedUser; use api::http::{Json, Path, State}; use api::rest::{AppResponseData, NoData}; use crate::errors::ApiError; use crate::services::dto::SpacePath; use crate::services::groups::{CreateGroupCmd, GroupDto}; use crate::services::service::SpaceService; #[utoipa::path( post, path = "/spaces/{space_name}/groups", tag = "space", description = "创建空间群组并为其授予合法权限集合。", params(SpacePath), request_body = CreateGroupCmd, responses( (status = 200, description = "group created", body = AppResponseData), (status = 400, description = "bad request", body = AppResponseData), (status = 403, description = "forbidden", body = AppResponseData), (status = 404, description = "space not found", body = AppResponseData), (status = 409, description = "group name conflict", body = AppResponseData), (status = 401, description = "authentication required", body = AppResponseData) ) )] pub async fn create_group( State(service): State, AuthedUser(uid): AuthedUser, Path(path): Path, Json(cmd): Json, ) -> Result, ApiError> { let group = service.create_group(uid, &path.space_name, cmd).await?; Ok(AppResponseData::ok(group)) }