use serde::{Deserialize, Serialize}; use chrono::{DateTime, Utc}; /// 分组策略 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GroupingStrategy { /// 主要分组维度 pub primary_dimension: String, /// 分组原因说明 pub reasoning: String, } /// 方案质量评分 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OutfitQualityScore { /// AI对该方案的信心度 (0-1) pub ai_confidence_score: f32, /// TikTok趋势匹配度 (0-1) pub trend_score: f32, /// 搭配versatility评分 (0-1) pub versatility_score: f32, /// 搭配难度等级 pub difficulty_level: String, /// 整体推荐度 (0-1) pub overall_recommendation_score: f32, } /// 穿搭方案分组 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OutfitRecommendationGroup { /// 分组名称 pub group: String, /// 分组描述 pub description: String, /// 分组唯一标识符 pub group_id: String, /// 该分组的风格关键词 pub style_keywords: Vec, /// 是否可以加载更多方案 pub can_load_more: bool, /// 分组下的方案列表 pub children: Vec, } /// 色彩信息 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ColorInfo { /// 色彩名称 pub name: String, /// 十六进制色值 pub hex: String, /// HSV值 (0-1范围) pub hsv: (f32, f32, f32), } /// 穿搭单品 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OutfitItem { /// 单品类别 (如: "上装", "下装", "鞋子", "配饰") pub category: String, /// 单品描述 pub description: String, /// 主要颜色 pub primary_color: ColorInfo, /// 次要颜色 (可选) pub secondary_color: Option, /// 材质 pub material: String, /// 风格标签 pub style_tags: Vec, } /// 场景建议 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SceneRecommendation { /// 场景名称 pub name: String, /// 场景描述 pub description: String, /// 场景类型 ("室内", "室外", "特殊") pub scene_type: String, /// 适合的时间段 pub time_of_day: Vec, /// 光线条件 pub lighting: String, /// 拍摄建议 pub photography_tips: Vec, } /// 穿搭方案 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OutfitRecommendation { /// 方案ID pub id: String, /// 方案标题 pub title: String, /// 方案描述 pub description: String, /// 整体风格 pub overall_style: String, /// 风格标签 pub style_tags: Vec, /// 适合场合 pub occasions: Vec, /// 适合季节 pub seasons: Vec, /// 穿搭单品列表 pub items: Vec, /// 色彩搭配主题 pub color_theme: String, /// 主要色彩 pub primary_colors: Vec, /// 场景建议 pub scene_recommendations: Vec, /// TikTok优化建议 pub tiktok_tips: Vec, /// 搭配要点 pub styling_tips: Vec, /// 创建时间 pub created_at: DateTime, /// 方案质量评分 pub quality_score: OutfitQualityScore, } /// 穿搭方案生成请求 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OutfitRecommendationRequest { /// 用户输入的关键词或描述 pub query: String, /// 目标风格 (可选) pub target_style: Option, /// 适合场合 (可选) pub occasions: Option>, /// 季节偏好 (可选) pub season: Option, /// 色彩偏好 (可选) pub color_preferences: Option>, /// 生成数量 pub count: u32, } /// 穿搭方案生成响应 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OutfitRecommendationResponse { /// 分组策略 pub grouping_strategy: GroupingStrategy, /// 生成的穿搭方案分组列表 pub groups: Vec, /// 生成时间 (毫秒) pub generation_time_ms: u64, /// 生成时间戳 pub generated_at: DateTime, /// 使用的提示词 (调试用) pub prompt_used: Option, // 保持向后兼容性 /// 生成的穿搭方案列表 (向后兼容) #[serde(skip_serializing_if = "Vec::is_empty")] pub recommendations: Vec, } /// 场景检索请求 (用于方案详情到场景检索的集成) #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SceneSearchRequest { /// 穿搭方案ID pub outfit_id: String, /// 场景描述 pub scene_description: String, /// 风格标签 pub style_tags: Vec, /// 色彩信息 pub colors: Vec, /// 搜索参数 pub search_params: SceneSearchParams, } /// 场景检索参数 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SceneSearchParams { /// 场景类型过滤 pub scene_types: Option>, /// 时间段过滤 pub time_filters: Option>, /// 光线条件过滤 pub lighting_filters: Option>, /// 结果数量限制 pub limit: Option, } impl Default for OutfitRecommendationRequest { fn default() -> Self { Self { query: String::new(), target_style: None, occasions: None, season: None, color_preferences: None, count: 12, // 默认生成12个方案 } } } impl OutfitRecommendation { /// 生成用于场景检索的描述 pub fn generate_scene_search_description(&self) -> String { let mut description = format!("{} - {}", self.title, self.description); if !self.style_tags.is_empty() { description.push_str(&format!(" 风格: {}", self.style_tags.join(", "))); } if !self.primary_colors.is_empty() { let color_names: Vec = self.primary_colors.iter() .map(|c| c.name.clone()) .collect(); description.push_str(&format!(" 主要色彩: {}", color_names.join(", "))); } description } /// 获取所有风格标签 (包括整体风格和单品风格) pub fn get_all_style_tags(&self) -> Vec { let mut all_tags = self.style_tags.clone(); // 添加整体风格 if !self.overall_style.is_empty() { all_tags.push(self.overall_style.clone()); } // 添加单品风格标签 for item in &self.items { all_tags.extend(item.style_tags.clone()); } // 去重并排序 all_tags.sort(); all_tags.dedup(); all_tags } }