重构(会员契约): 充值中心会员状态改用强类型 token
- ProfileMembershipResponse.status 由裸 String 改为 ProfileMembershipStatusToken,与前端 ProfileMembershipStatus 对齐 - BFF 直接用 From<RuntimeProfileMembershipStatus> 转换,测试改用具名枚举
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<String>,
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user