use api::http::State; use api::rest::{AppResponseData, NoData}; use serde::Serialize; use utoipa::ToSchema; use crate::AuthService; use crate::errors::ApiError; use crate::services::profile::{ProfileDto, UserMeDto}; use ::session::AuthedUser; #[derive(Debug, Clone, Serialize, ToSchema)] pub struct MeResp { pub user: UserMeDto, pub profile: Option, } #[utoipa::path( get, path = "/me", tag = "account", description = "返回当前登录用户的身份、账号状态与资料。", responses( (status = 200, description = "identity and profile of the active user", body = AppResponseData), (status = 404, description = "resource not found", body = AppResponseData), (status = 401, description = "authentication required", body = AppResponseData) ) )] pub async fn me( State(service): State, AuthedUser(uid): AuthedUser, ) -> Result, ApiError> { let (user, profile) = service.account_me(uid).await.map_err(ApiError::from)?; Ok(AppResponseData::ok(MeResp { user, profile })) }