From cc0c07223c8977b7cfec2f2ecaed534c727efb3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Mon, 5 Oct 2026 12:22:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84(=E4=BC=9A=E5=91=98=E5=A5=91?= =?UTF-8?q?=E7=BA=A6):=20=E5=85=85=E5=80=BC=E4=B8=AD=E5=BF=83=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E7=8A=B6=E6=80=81=E6=94=B9=E7=94=A8=E5=BC=BA=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ProfileMembershipResponse.status 由裸 String 改为 ProfileMembershipStatusToken,与前端 ProfileMembershipStatus 对齐 - BFF 直接用 From 转换,测试改用具名枚举 --- server-rs/crates/api-server/src/runtime_profile.rs | 2 +- server-rs/crates/shared-contracts/src/runtime.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server-rs/crates/api-server/src/runtime_profile.rs b/server-rs/crates/api-server/src/runtime_profile.rs index 13ff54860..8e88dcfe9 100644 --- a/server-rs/crates/api-server/src/runtime_profile.rs +++ b/server-rs/crates/api-server/src/runtime_profile.rs @@ -1914,7 +1914,7 @@ fn build_profile_recharge_center_response( ProfileRechargeCenterResponse { mud_point_balance, membership: ProfileMembershipResponse { - status: record.membership.status.as_str().to_string(), + status: record.membership.status.into(), plan: record.membership.plan.into(), started_at: record.membership.started_at, expires_at: record.membership.expires_at, diff --git a/server-rs/crates/shared-contracts/src/runtime.rs b/server-rs/crates/shared-contracts/src/runtime.rs index 6de475871..be73898d7 100644 --- a/server-rs/crates/shared-contracts/src/runtime.rs +++ b/server-rs/crates/shared-contracts/src/runtime.rs @@ -433,7 +433,8 @@ pub struct ProfileMembershipPlanResponse { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct ProfileMembershipResponse { - pub status: String, + /// 会员状态 token:`normal` / `active`。 + pub status: ProfileMembershipStatusToken, /// 当前档位 token;非会员与已到期都是 `normal`。 pub plan: ProfileMembershipPlanToken, pub started_at: Option, @@ -1819,7 +1820,7 @@ mod tests { permanent_points: 4, }, membership: ProfileMembershipResponse { - status: "active".to_string(), + status: ProfileMembershipStatusToken::Active, plan: ProfileMembershipPlanToken::Plus, started_at: Some("2026-04-25T10:00:00Z".to_string()), expires_at: Some("2026-05-25T10:00:00Z".to_string()), @@ -1929,7 +1930,7 @@ mod tests { let center = ProfileRechargeCenterResponse { mud_point_balance: empty_mud_point_balance(), membership: ProfileMembershipResponse { - status: "normal".to_string(), + status: ProfileMembershipStatusToken::Normal, plan: ProfileMembershipPlanToken::Normal, started_at: None, expires_at: None, @@ -2005,7 +2006,7 @@ mod tests { let center = ProfileRechargeCenterResponse { mud_point_balance: empty_mud_point_balance(), membership: ProfileMembershipResponse { - status: "normal".to_string(), + status: ProfileMembershipStatusToken::Normal, plan: ProfileMembershipPlanToken::Normal, started_at: None, expires_at: None,