diff --git a/crates/rtss_api/src/apis/release_data.rs b/crates/rtss_api/src/apis/release_data.rs index e8da824..8b31f26 100644 --- a/crates/rtss_api/src/apis/release_data.rs +++ b/crates/rtss_api/src/apis/release_data.rs @@ -372,6 +372,7 @@ pub struct ReleaseDataWithUsedVersionDto { } #[derive(Debug, SimpleObject)] +#[graphql(complex)] pub struct ReleaseDataVersionDto { pub id: i32, pub release_data_id: i32, @@ -383,6 +384,16 @@ pub struct ReleaseDataVersionDto { pub created_at: NaiveDateTime, } +#[ComplexObject] +impl ReleaseDataVersionDto { + /// 获取用户name + async fn user_name(&self, ctx: &Context<'_>) -> async_graphql::Result> { + let loader = ctx.data_unchecked::>(); + let name = loader.load_one(UserId::new(self.user_id)).await?; + Ok(name) + } +} + impl From<(ReleaseDataModel, ReleaseDataVersionModel)> for ReleaseDataWithUsedVersionDto { fn from((data, version): (ReleaseDataModel, ReleaseDataVersionModel)) -> Self { Self {