This commit is contained in:
2026-05-01 01:30:02 +08:00
parent aabad6407f
commit 2e9d0f4640
92 changed files with 4548 additions and 248 deletions

View File

@@ -47,11 +47,61 @@ pub struct PuzzleWorkSummaryResponse {
pub like_count: u32,
#[serde(default)]
pub recent_play_count_7d: u32,
#[serde(default)]
pub point_incentive_total_half_points: u64,
#[serde(default)]
pub point_incentive_claimed_points: u64,
#[serde(default)]
pub point_incentive_total_points: f64,
#[serde(default)]
pub point_incentive_claimable_points: u64,
pub publish_ready: bool,
#[serde(default)]
pub levels: Vec<PuzzleDraftLevelResponse>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn puzzle_work_summary_response_uses_point_incentive_fields() {
let payload = serde_json::to_value(PuzzleWorkSummaryResponse {
work_id: "work-1".to_string(),
profile_id: "profile-1".to_string(),
owner_user_id: "user-1".to_string(),
source_session_id: None,
author_display_name: "作者".to_string(),
work_title: "作品".to_string(),
work_description: "描述".to_string(),
level_name: "第一关".to_string(),
summary: "画面".to_string(),
theme_tags: vec!["拼图".to_string(), "夜色".to_string(), "灯光".to_string()],
cover_image_src: None,
cover_asset_id: None,
publication_status: "published".to_string(),
updated_at: "2026-05-01T00:00:00Z".to_string(),
published_at: Some("2026-05-01T00:00:00Z".to_string()),
play_count: 1,
remix_count: 0,
like_count: 0,
recent_play_count_7d: 1,
point_incentive_total_half_points: 3,
point_incentive_claimed_points: 1,
point_incentive_total_points: 1.5,
point_incentive_claimable_points: 0,
publish_ready: true,
levels: Vec::new(),
})
.expect("payload should serialize");
assert_eq!(payload["pointIncentiveTotalHalfPoints"], 3);
assert_eq!(payload["pointIncentiveClaimedPoints"], 1);
assert_eq!(payload["pointIncentiveTotalPoints"], 1.5);
assert_eq!(payload["pointIncentiveClaimablePoints"], 0);
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PuzzleWorkProfileResponse {

View File

@@ -11,6 +11,8 @@ pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_ASSET_OPERATION_CONSUME: &str =
"asset_operation_consume";
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_ASSET_OPERATION_REFUND: &str = "asset_operation_refund";
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_REDEEM_CODE_REWARD: &str = "redeem_code_reward";
pub const PROFILE_WALLET_LEDGER_SOURCE_TYPE_PUZZLE_AUTHOR_INCENTIVE_CLAIM: &str =
"puzzle_author_incentive_claim";
pub const BROWSE_HISTORY_THEME_MODE_MARTIAL: &str = "martial";
pub const BROWSE_HISTORY_THEME_MODE_ARCANE: &str = "arcane";
pub const BROWSE_HISTORY_THEME_MODE_MACHINA: &str = "machina";
@@ -910,6 +912,14 @@ mod tests {
.to_string(),
created_at: "2026-04-22T10:05:00Z".to_string(),
},
ProfileWalletLedgerEntryResponse {
id: "ledger-7".to_string(),
amount_delta: 2,
balance_after: 202,
source_type: PROFILE_WALLET_LEDGER_SOURCE_TYPE_PUZZLE_AUTHOR_INCENTIVE_CLAIM
.to_string(),
created_at: "2026-04-22T10:06:00Z".to_string(),
},
],
})
.expect("payload should serialize");
@@ -940,6 +950,10 @@ mod tests {
payload["entries"][5]["sourceType"],
json!(PROFILE_WALLET_LEDGER_SOURCE_TYPE_ASSET_OPERATION_REFUND)
);
assert_eq!(
payload["entries"][6]["sourceType"],
json!(PROFILE_WALLET_LEDGER_SOURCE_TYPE_PUZZLE_AUTHOR_INCENTIVE_CLAIM)
);
assert_eq!(
payload["entries"][0]["createdAt"],
json!("2026-04-22T10:00:00Z")