feat: 支持创作入口公告配置
This commit is contained in:
@@ -1154,9 +1154,11 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// 构造不携带资产覆盖的 JumpHop action,单测按需再覆盖字段。
|
||||
fn action(action_type: JumpHopActionType) -> JumpHopActionRequest {
|
||||
JumpHopActionRequest {
|
||||
action_type,
|
||||
profile_id: None,
|
||||
work_title: None,
|
||||
work_description: None,
|
||||
theme_tags: None,
|
||||
@@ -1165,6 +1167,10 @@ mod tests {
|
||||
character_prompt: None,
|
||||
tile_prompt: None,
|
||||
end_mood_prompt: None,
|
||||
character_asset: None,
|
||||
tile_atlas_asset: None,
|
||||
tile_assets: None,
|
||||
cover_composite: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ mod tests {
|
||||
let row = BarkBattleGalleryViewRow {
|
||||
work_id: "BB-33333333".to_string(),
|
||||
owner_user_id: "user-3".to_string(),
|
||||
author_display_name: "声浪玩家".to_string(),
|
||||
source_draft_id: Some("bark-battle-draft-3".to_string()),
|
||||
config_version: 1,
|
||||
ruleset_version: "bark-battle-ruleset-v1".to_string(),
|
||||
|
||||
@@ -19,6 +19,17 @@ impl From<module_runtime::CreationEntryTypeAdminUpsertInput> for CreationEntryTy
|
||||
}
|
||||
}
|
||||
|
||||
/// 将业务层 banner JSON 保存输入转换为 SpacetimeDB 生成绑定类型。
|
||||
impl From<module_runtime::CreationEntryEventBannersAdminUpsertInput>
|
||||
for CreationEntryEventBannersAdminUpsertInput
|
||||
{
|
||||
fn from(input: module_runtime::CreationEntryEventBannersAdminUpsertInput) -> Self {
|
||||
Self {
|
||||
event_banners_json: input.event_banners_json,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<module_runtime::AdminWorkVisibilityListInput> for AdminWorkVisibilityListInput {
|
||||
fn from(input: module_runtime::AdminWorkVisibilityListInput) -> Self {
|
||||
Self {
|
||||
@@ -233,6 +244,7 @@ fn map_admin_work_visibility_snapshot(
|
||||
}
|
||||
}
|
||||
|
||||
/// 从本地订阅表行组装创作入口配置响应,兼容旧单条 banner 字段。
|
||||
pub(crate) fn build_creation_entry_config_record_from_rows(
|
||||
header: CreationEntryConfig,
|
||||
mut creation_types: Vec<CreationEntryTypeConfig>,
|
||||
@@ -278,7 +290,10 @@ pub(crate) fn build_creation_entry_config_record_from_rows(
|
||||
header.event_ends_at_text,
|
||||
module_runtime::DEFAULT_CREATION_ENTRY_EVENT_ENDS_AT_TEXT,
|
||||
),
|
||||
render_mode: "structured".to_string(),
|
||||
html_code: None,
|
||||
},
|
||||
event_banners_json: header.event_banners_json,
|
||||
creation_types: creation_types
|
||||
.into_iter()
|
||||
.map(|item| module_runtime::CreationEntryTypeSnapshot {
|
||||
@@ -308,6 +323,7 @@ pub(crate) fn build_creation_entry_config_record_from_rows(
|
||||
)
|
||||
}
|
||||
|
||||
/// 将 SpacetimeDB procedure 快照映射为 module-runtime 领域快照。
|
||||
fn map_creation_entry_config_snapshot(
|
||||
snapshot: CreationEntryConfigSnapshot,
|
||||
) -> module_runtime::CreationEntryConfigSnapshot {
|
||||
@@ -330,7 +346,10 @@ fn map_creation_entry_config_snapshot(
|
||||
prize_pool_mud_points: snapshot.event_banner.prize_pool_mud_points,
|
||||
starts_at_text: snapshot.event_banner.starts_at_text,
|
||||
ends_at_text: snapshot.event_banner.ends_at_text,
|
||||
render_mode: snapshot.event_banner.render_mode,
|
||||
html_code: snapshot.event_banner.html_code,
|
||||
},
|
||||
event_banners_json: snapshot.event_banners_json,
|
||||
creation_types: snapshot
|
||||
.creation_types
|
||||
.into_iter()
|
||||
|
||||
@@ -242,6 +242,7 @@ pub mod creation_entry_config_snapshot_type;
|
||||
pub mod creation_entry_config_table;
|
||||
pub mod creation_entry_config_type;
|
||||
pub mod creation_entry_event_banner_snapshot_type;
|
||||
pub mod creation_entry_event_banners_admin_upsert_input_type;
|
||||
pub mod creation_entry_start_card_snapshot_type;
|
||||
pub mod creation_entry_type_admin_upsert_input_type;
|
||||
pub mod creation_entry_type_config_table;
|
||||
@@ -949,6 +950,7 @@ pub mod update_visual_novel_work_procedure;
|
||||
pub mod update_wooden_fish_work_procedure;
|
||||
pub mod upsert_chapter_progression_and_return_procedure;
|
||||
pub mod upsert_chapter_progression_reducer;
|
||||
pub mod upsert_creation_entry_event_banners_config_procedure;
|
||||
pub mod upsert_creation_entry_type_config_procedure;
|
||||
pub mod upsert_custom_world_agent_operation_progress_procedure;
|
||||
pub mod upsert_custom_world_profile_and_return_procedure;
|
||||
@@ -1281,6 +1283,7 @@ pub use creation_entry_config_snapshot_type::CreationEntryConfigSnapshot;
|
||||
pub use creation_entry_config_table::*;
|
||||
pub use creation_entry_config_type::CreationEntryConfig;
|
||||
pub use creation_entry_event_banner_snapshot_type::CreationEntryEventBannerSnapshot;
|
||||
pub use creation_entry_event_banners_admin_upsert_input_type::CreationEntryEventBannersAdminUpsertInput;
|
||||
pub use creation_entry_start_card_snapshot_type::CreationEntryStartCardSnapshot;
|
||||
pub use creation_entry_type_admin_upsert_input_type::CreationEntryTypeAdminUpsertInput;
|
||||
pub use creation_entry_type_config_table::*;
|
||||
@@ -1988,6 +1991,7 @@ pub use update_visual_novel_work_procedure::update_visual_novel_work;
|
||||
pub use update_wooden_fish_work_procedure::update_wooden_fish_work;
|
||||
pub use upsert_chapter_progression_and_return_procedure::upsert_chapter_progression_and_return;
|
||||
pub use upsert_chapter_progression_reducer::upsert_chapter_progression;
|
||||
pub use upsert_creation_entry_event_banners_config_procedure::upsert_creation_entry_event_banners_config;
|
||||
pub use upsert_creation_entry_type_config_procedure::upsert_creation_entry_type_config;
|
||||
pub use upsert_custom_world_agent_operation_progress_procedure::upsert_custom_world_agent_operation_progress;
|
||||
pub use upsert_custom_world_profile_and_return_procedure::upsert_custom_world_profile_and_return;
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct CreationEntryConfigSnapshot {
|
||||
pub start_card: CreationEntryStartCardSnapshot,
|
||||
pub type_modal: CreationEntryTypeModalSnapshot,
|
||||
pub event_banner: CreationEntryEventBannerSnapshot,
|
||||
pub event_banners_json: Option<String>,
|
||||
pub creation_types: Vec<CreationEntryTypeSnapshot>,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ pub struct CreationEntryConfig {
|
||||
pub event_prize_pool_mud_points: u64,
|
||||
pub event_starts_at_text: Option<String>,
|
||||
pub event_ends_at_text: Option<String>,
|
||||
pub event_banners_json: Option<String>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for CreationEntryConfig {
|
||||
@@ -45,6 +46,7 @@ pub struct CreationEntryConfigCols {
|
||||
pub event_prize_pool_mud_points: __sdk::__query_builder::Col<CreationEntryConfig, u64>,
|
||||
pub event_starts_at_text: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
|
||||
pub event_ends_at_text: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
|
||||
pub event_banners_json: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasCols for CreationEntryConfig {
|
||||
@@ -74,6 +76,7 @@ impl __sdk::__query_builder::HasCols for CreationEntryConfig {
|
||||
"event_starts_at_text",
|
||||
),
|
||||
event_ends_at_text: __sdk::__query_builder::Col::new(table_name, "event_ends_at_text"),
|
||||
event_banners_json: __sdk::__query_builder::Col::new(table_name, "event_banners_json"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ pub struct CreationEntryEventBannerSnapshot {
|
||||
pub prize_pool_mud_points: u64,
|
||||
pub starts_at_text: String,
|
||||
pub ends_at_text: String,
|
||||
pub render_mode: String,
|
||||
pub html_code: Option<String>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for CreationEntryEventBannerSnapshot {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct CreationEntryEventBannersAdminUpsertInput {
|
||||
pub event_banners_json: String,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for CreationEntryEventBannersAdminUpsertInput {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::creation_entry_config_procedure_result_type::CreationEntryConfigProcedureResult;
|
||||
use super::creation_entry_event_banners_admin_upsert_input_type::CreationEntryEventBannersAdminUpsertInput;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
struct UpsertCreationEntryEventBannersConfigArgs {
|
||||
pub input: CreationEntryEventBannersAdminUpsertInput,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for UpsertCreationEntryEventBannersConfigArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the procedure `upsert_creation_entry_event_banners_config`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteProcedures`].
|
||||
pub trait upsert_creation_entry_event_banners_config {
|
||||
fn upsert_creation_entry_event_banners_config(
|
||||
&self,
|
||||
input: CreationEntryEventBannersAdminUpsertInput,
|
||||
) {
|
||||
self.upsert_creation_entry_event_banners_config_then(input, |_, _| {});
|
||||
}
|
||||
|
||||
fn upsert_creation_entry_event_banners_config_then(
|
||||
&self,
|
||||
input: CreationEntryEventBannersAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<CreationEntryConfigProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
impl upsert_creation_entry_event_banners_config for super::RemoteProcedures {
|
||||
fn upsert_creation_entry_event_banners_config_then(
|
||||
&self,
|
||||
input: CreationEntryEventBannersAdminUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<CreationEntryConfigProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, CreationEntryConfigProcedureResult>(
|
||||
"upsert_creation_entry_event_banners_config",
|
||||
UpsertCreationEntryEventBannersConfigArgs { input },
|
||||
__callback,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,34 @@ impl SpacetimeClient {
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
/// 调用 SpacetimeDB procedure 保存创作入口页多 banner 配置并刷新缓存。
|
||||
pub async fn upsert_creation_entry_event_banners_config(
|
||||
&self,
|
||||
input: module_runtime::CreationEntryEventBannersAdminUpsertInput,
|
||||
) -> Result<CreationEntryConfigRecord, SpacetimeClientError> {
|
||||
let procedure_input: CreationEntryEventBannersAdminUpsertInput = input.into();
|
||||
let config = self
|
||||
.call_after_connect(
|
||||
"upsert_creation_entry_event_banners_config",
|
||||
move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.upsert_creation_entry_event_banners_config_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(SpacetimeClientError::from_sdk_error)
|
||||
.and_then(map_creation_entry_config_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
self.cache_creation_entry_config(config.clone()).await;
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub async fn admin_list_work_visibility(
|
||||
&self,
|
||||
admin_user_id: String,
|
||||
|
||||
Reference in New Issue
Block a user