From 5603185a7fb7848454245d4a1652e1a7006a6504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 3 Oct 2026 19:39:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BC=9A=E5=91=98=E6=8A=A5=E4=BB=B7):?= =?UTF-8?q?=20=E5=8D=87=E7=BA=A7=E6=8A=A5=E4=BB=B7=E5=BF=AB=E7=85=A7?= =?UTF-8?q?=E6=A1=A3=E4=BD=8D=E4=B8=8E=E5=91=A8=E6=9C=9F=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - RuntimeProfileMembershipUpgradeQuoteSnapshot 的 current_plan / target_plan / cycle_kind 由 String 改为 RuntimeProfileMembershipPlan / RuntimeProfileMembershipCycleKind,把非法值挡在类型边界外。 - 模块构造点直接写入枚举;记录侧在 build_runtime_profile_membership_upgrade_quote_record 用 as_str() 转回对外 token,HTTP 契约不变。 - spacetime-client 映射改用 plan / cycle_kind 的 back 映射还原枚举;重新生成 module_bindings。 --- server-rs/crates/module-runtime/src/application.rs | 6 +++--- server-rs/crates/module-runtime/src/domain.rs | 6 +++--- .../src/active/mapper/runtime_profile.rs | 6 +++--- ...ime_profile_membership_upgrade_quote_snapshot_type.rs | 9 ++++++--- .../spacetime-module/src/runtime/active/profile.rs | 6 +++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/server-rs/crates/module-runtime/src/application.rs b/server-rs/crates/module-runtime/src/application.rs index 38454c755..ab4f9d49a 100644 --- a/server-rs/crates/module-runtime/src/application.rs +++ b/server-rs/crates/module-runtime/src/application.rs @@ -1132,9 +1132,9 @@ pub fn build_runtime_profile_membership_upgrade_quote_record( snapshot: RuntimeProfileMembershipUpgradeQuoteSnapshot, ) -> RuntimeProfileMembershipUpgradeQuoteRecord { RuntimeProfileMembershipUpgradeQuoteRecord { - current_plan: snapshot.current_plan, - target_plan: snapshot.target_plan, - cycle_kind: snapshot.cycle_kind, + current_plan: snapshot.current_plan.as_str().to_string(), + target_plan: snapshot.target_plan.as_str().to_string(), + cycle_kind: snapshot.cycle_kind.as_str().to_string(), cycle_index: snapshot.cycle_index, cycle_count: snapshot.cycle_count, amount_cents: snapshot.amount_cents, diff --git a/server-rs/crates/module-runtime/src/domain.rs b/server-rs/crates/module-runtime/src/domain.rs index b94aa6476..53dba4bec 100644 --- a/server-rs/crates/module-runtime/src/domain.rs +++ b/server-rs/crates/module-runtime/src/domain.rs @@ -1892,9 +1892,9 @@ pub struct RuntimeProfileMembershipUpgradeQuoteGetInput { #[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct RuntimeProfileMembershipUpgradeQuoteSnapshot { - pub current_plan: String, - pub target_plan: String, - pub cycle_kind: String, + pub current_plan: RuntimeProfileMembershipPlan, + pub target_plan: RuntimeProfileMembershipPlan, + pub cycle_kind: RuntimeProfileMembershipCycleKind, pub cycle_index: u32, pub cycle_count: u32, pub amount_cents: u64, diff --git a/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs b/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs index 591dd1209..311352f13 100644 --- a/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs +++ b/server-rs/crates/spacetime-client/src/active/mapper/runtime_profile.rs @@ -2119,9 +2119,9 @@ pub(crate) fn map_runtime_profile_membership_upgrade_quote_procedure_result( Ok(build_runtime_profile_membership_upgrade_quote_record( module_runtime::RuntimeProfileMembershipUpgradeQuoteSnapshot { - current_plan: quote.current_plan, - target_plan: quote.target_plan, - cycle_kind: quote.cycle_kind, + current_plan: map_runtime_profile_membership_plan_back(quote.current_plan), + target_plan: map_runtime_profile_membership_plan_back(quote.target_plan), + cycle_kind: map_runtime_profile_membership_cycle_kind_back(quote.cycle_kind), cycle_index: quote.cycle_index, cycle_count: quote.cycle_count, amount_cents: quote.amount_cents, diff --git a/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_membership_upgrade_quote_snapshot_type.rs b/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_membership_upgrade_quote_snapshot_type.rs index 1ffc80dc3..e3a9ddb6b 100644 --- a/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_membership_upgrade_quote_snapshot_type.rs +++ b/server-rs/crates/spacetime-client/src/module_bindings/runtime_profile_membership_upgrade_quote_snapshot_type.rs @@ -4,12 +4,15 @@ #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; +use super::runtime_profile_membership_cycle_kind_type::RuntimeProfileMembershipCycleKind; +use super::runtime_profile_membership_plan_type::RuntimeProfileMembershipPlan; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct RuntimeProfileMembershipUpgradeQuoteSnapshot { - pub current_plan: String, - pub target_plan: String, - pub cycle_kind: String, + pub current_plan: RuntimeProfileMembershipPlan, + pub target_plan: RuntimeProfileMembershipPlan, + pub cycle_kind: RuntimeProfileMembershipCycleKind, pub cycle_index: u32, pub cycle_count: u32, pub amount_cents: u64, diff --git a/server-rs/crates/spacetime-module/src/runtime/active/profile.rs b/server-rs/crates/spacetime-module/src/runtime/active/profile.rs index 9309abed6..40d91ceaf 100644 --- a/server-rs/crates/spacetime-module/src/runtime/active/profile.rs +++ b/server-rs/crates/spacetime-module/src/runtime/active/profile.rs @@ -8279,9 +8279,9 @@ fn build_profile_membership_upgrade_quote_record( .map_err(|rejection| format!("会员升级被拒绝: {}", rejection.as_str()))?; Ok(RuntimeProfileMembershipUpgradeQuoteSnapshot { - current_plan: current.plan.as_str().to_string(), - target_plan: target.plan.as_str().to_string(), - cycle_kind: target.cycle_kind.as_str().to_string(), + current_plan: current.plan, + target_plan: target.plan, + cycle_kind: target.cycle_kind, cycle_index: quote.cycle_index, cycle_count: target.cycle_count, amount_cents: quote.amount_cents,