Files
Genarrative/server-rs/crates/shared-contracts/src/public_work.rs

64 lines
2.0 KiB
Rust

use serde::{Deserialize, Serialize};
/// 公开作品列表统一契约。
///
/// 该契约面向 BFF 和后续可选前端直连订阅,字段只包含平台公开卡片需要的摘要信息。
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PublicWorkGalleryEntryResponse {
pub source_type: String,
pub work_id: String,
pub profile_id: String,
#[serde(default)]
pub source_session_id: Option<String>,
pub public_work_code: String,
pub owner_user_id: String,
pub author_display_name: String,
pub world_name: String,
pub subtitle: String,
pub summary_text: String,
#[serde(default)]
pub cover_image_src: Option<String>,
#[serde(default)]
pub cover_asset_id: Option<String>,
pub theme_tags: Vec<String>,
pub play_count: u32,
pub remix_count: u32,
pub like_count: u32,
#[serde(default)]
pub recent_play_count_7d: u32,
#[serde(default)]
pub published_at: Option<String>,
pub updated_at: String,
pub sort_time_micros: i64,
}
/// 公开作品详情统一摘要契约。
///
/// `detail_payload_json` 只承载详情页展示扩展字段,不承载正式 runtime 配置。
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PublicWorkDetailEntryResponse {
#[serde(flatten)]
pub entry: PublicWorkGalleryEntryResponse,
pub detail_payload_json: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PublicWorkGalleryResponse {
pub items: Vec<PublicWorkGalleryEntryResponse>,
#[serde(default)]
pub has_more: bool,
#[serde(default)]
pub next_cursor: Option<String>,
#[serde(default)]
pub total_count: u32,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PublicWorkDetailResponse {
pub item: PublicWorkDetailEntryResponse,
}