Skip to content
Clone
main
39 lines 1.2 KB Rust
use ::session::OptionalUser;
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::groups::GroupDto;
use crate::services::service::SpaceService;
#[derive(Debug, Clone, Deserialize, IntoParams, ToSchema)]
pub struct GroupPath {
pub space_name: String,
pub group_id: Uuid,
}
#[utoipa::path(
get,
path = "/spaces/{space_name}/groups/{group_id}",
tag = "space",
description = "读取群组详情,并按空间可见性规则控制访问。",
params(GroupPath),
responses(
(status = 200, description = "get group", body = AppResponseData<GroupDto>),
(status = 404, description = "group not found", body = AppResponseData<NoData>),
(status = 401, description = "authentication required", body = AppResponseData<NoData>)
)
)]
pub async fn get_group(
State(service): State<SpaceService>,
OptionalUser(caller): OptionalUser,
Path(path): Path<GroupPath>,
) -> Result<AppResponseData<GroupDto>, ApiError> {
let group = service
.get_group(caller, &path.space_name, path.group_id)
.await?;
Ok(AppResponseData::ok(group))
}