main
use ::session::AuthedUser;
use api::http::{Json, Path, State};
use api::rest::{AppResponseData, NoData};
use crate::errors::ApiError;
use crate::handlers::get_group::GroupPath;
use crate::services::groups::{GroupDto, UpdateGroupCmd};
use crate::services::service::SpaceService;
#[utoipa::path(
patch,
path = "/spaces/{space_name}/groups/{group_id}",
tag = "space",
description = "更新群组名称、图标、排序或整体权限集合。",
params(GroupPath),
request_body = UpdateGroupCmd,
responses(
(status = 200, description = "group updated", body = AppResponseData<GroupDto>),
(status = 400, description = "bad request", body = AppResponseData<NoData>),
(status = 403, description = "forbidden", body = AppResponseData<NoData>),
(status = 404, description = "not found", body = AppResponseData<NoData>),
(status = 409, description = "group name conflict", body = AppResponseData<NoData>),
(status = 401, description = "authentication required", body = AppResponseData<NoData>)
)
)]
pub async fn update_group(
State(service): State<SpaceService>,
AuthedUser(uid): AuthedUser,
Path(path): Path<GroupPath>,
Json(cmd): Json<UpdateGroupCmd>,
) -> Result<AppResponseData<GroupDto>, ApiError> {
let group = service
.update_group(uid, &path.space_name, path.group_id, cmd)
.await?;
Ok(AppResponseData::ok(group))
}