refactor: modularize api server assets and handlers

This commit is contained in:
2026-05-14 22:54:52 +08:00
parent 4ba1ebbbdf
commit 1b54db4f92
47 changed files with 8081 additions and 6142 deletions

View File

@@ -13,8 +13,8 @@ use module_match3d::{
Match3DItemSnapshot as DomainMatch3DItemSnapshot, Match3DItemState as DomainMatch3DItemState,
Match3DRunSnapshot as DomainMatch3DRunSnapshot, Match3DRunStatus as DomainMatch3DRunStatus,
Match3DTraySlot as DomainMatch3DTraySlot, confirm_click_at as confirm_domain_click_at,
resolve_run_timer_at as resolve_domain_run_timer_at, start_run_with_seed_at_and_item_type_count,
stop_run_at as stop_domain_run_at,
resolve_run_timer_at as resolve_domain_run_timer_at,
start_run_with_seed_at_and_item_type_count, stop_run_at as stop_domain_run_at,
};
use serde::Serialize;
use serde::de::DeserializeOwned;
@@ -1251,12 +1251,12 @@ fn validate_publishable_work(row: &Match3DWorkProfileRow) -> Result<(), String>
return Err("match3d 发布需要至少 1 个标签".to_string());
}
let config = parse_config(&row.config_json)?;
let required_item_types =
module_match3d::resolve_match3d_item_type_count_for_difficulty(
config.clear_count,
config.difficulty,
) as usize;
let ready_item_types = count_ready_generated_item_types(row.generated_item_assets_json.as_deref())?;
let required_item_types = module_match3d::resolve_match3d_item_type_count_for_difficulty(
config.clear_count,
config.difficulty,
) as usize;
let ready_item_types =
count_ready_generated_item_types(row.generated_item_assets_json.as_deref())?;
if ready_item_types < required_item_types {
return Err(format!(
"match3d 发布需要至少 {required_item_types} 种物品素材,当前已有 {ready_item_types}"

View File

@@ -17,15 +17,14 @@ use module_puzzle::{
PuzzleRunNextLevelInput, PuzzleRunPauseInput, PuzzleRunProcedureResult, PuzzleRunPropInput,
PuzzleRunSnapshot, PuzzleRunStartInput, PuzzleRunSwapInput, PuzzleRuntimeLevelStatus,
PuzzleSelectCoverImageInput, PuzzleUiBackgroundSaveInput, PuzzleWorkDeleteInput,
PuzzleWorkGetInput,
PuzzleWorkLikeRecordInput as PuzzleWorkLikeInput, PuzzleWorkPointIncentiveClaimInput,
PuzzleWorkProcedureResult, PuzzleWorkProfile, PuzzleWorkRemixInput, PuzzleWorkUpsertInput,
PuzzleWorksListInput, PuzzleWorksProcedureResult, apply_publish_overrides_to_draft,
apply_selected_candidate, build_form_draft_from_seed, build_result_preview,
compile_result_draft_from_seed, create_work_profile, infer_anchor_pack, normalize_puzzle_draft,
normalize_puzzle_levels, normalize_theme_tags, publish_work_profile, replace_puzzle_level,
select_next_profiles, selected_profile_level_after_runtime_level, selected_puzzle_level,
tag_similarity_score,
PuzzleWorkGetInput, PuzzleWorkLikeRecordInput as PuzzleWorkLikeInput,
PuzzleWorkPointIncentiveClaimInput, PuzzleWorkProcedureResult, PuzzleWorkProfile,
PuzzleWorkRemixInput, PuzzleWorkUpsertInput, PuzzleWorksListInput, PuzzleWorksProcedureResult,
apply_publish_overrides_to_draft, apply_selected_candidate, build_form_draft_from_seed,
build_result_preview, compile_result_draft_from_seed, create_work_profile, infer_anchor_pack,
normalize_puzzle_draft, normalize_puzzle_levels, normalize_theme_tags, publish_work_profile,
replace_puzzle_level, select_next_profiles, selected_profile_level_after_runtime_level,
selected_puzzle_level, tag_similarity_score,
};
use module_runtime::RuntimeProfileWalletLedgerSourceType;
use module_runtime::visible_runtime_profile_user_tags;
@@ -1062,12 +1061,10 @@ fn save_puzzle_ui_background_tx(
let mut next_level = target_level;
next_level.ui_background_prompt = Some(input.prompt.trim().to_string());
next_level.ui_background_image_src = Some(input.image_src.trim().to_string());
next_level.ui_background_image_object_key = input
.image_object_key
.and_then(|value| {
let trimmed = value.trim().to_string();
(!trimmed.is_empty()).then_some(trimmed)
});
next_level.ui_background_image_object_key = input.image_object_key.and_then(|value| {
let trimmed = value.trim().to_string();
(!trimmed.is_empty()).then_some(trimmed)
});
let draft = replace_puzzle_level(&draft, next_level).map_err(|error| error.to_string())?;
let saved_at = Timestamp::from_micros_since_unix_epoch(input.saved_at_micros);

View File

@@ -1,13 +1,13 @@
pub mod analytics_date_dimension;
pub mod creation_entry_config;
mod browse_history;
pub mod creation_entry_config;
mod profile;
mod settings;
mod snapshots;
pub use analytics_date_dimension::*;
pub use creation_entry_config::*;
pub use browse_history::*;
pub use creation_entry_config::*;
pub use profile::*;
pub use settings::*;
pub use snapshots::*;