|
@@ -1,212 +0,0 @@
|
|
|
-# 一、Schema范式设计
|
|
|
-## 个性化推荐模块
|
|
|
-- 模块描述 用户可以输入身高,体重,年龄,选择性别和输入补充信息(包括职业:非必填,喜好:非必填,天气:非必填,温度:非必填,其他需求:显高显瘦?儒雅甜美?等),AI会提供量身定制的服装和配饰建议并且保存AI生成的推荐结果以及用户信息和用户输入的信息。
|
|
|
-### 1.表结构设计
|
|
|
-#### UserProfile(用户表)
|
|
|
-- objectId:唯一标识符
|
|
|
-- createdAt:创建时间
|
|
|
-- height: Float (用户身高,以cm为单位)
|
|
|
-- weight: Float (用户体重,以kg为单位)
|
|
|
-- age: Integer (用户年龄)
|
|
|
-- gender: String (用户性别)
|
|
|
-- occupation: String (用户职业,非必填)
|
|
|
-- preferences: String (用户喜好,非必填)
|
|
|
-- weather: String (用户天气偏好,非必填)
|
|
|
-- temperature: String (用户温度偏好,非必填)
|
|
|
-- otherNeeds: String (其他需求,非必填)
|
|
|
-#### ClothingItem(服装表)
|
|
|
-- objectId:唯一标识符
|
|
|
-- createdAt:创建时间
|
|
|
-- name: String (服装名称)
|
|
|
-- type: String (服装类型,)
|
|
|
-- size: String (服装尺码,例如 "S", "M", "L", "XL")
|
|
|
-- color: String (服装颜色)
|
|
|
-- style: String (服装风格)
|
|
|
-- recommendedFor: Pointer (指向推荐给的用户)
|
|
|
-
|
|
|
-#### AccessoryItem(配饰表)
|
|
|
-
|
|
|
-- objectId:唯一标识符
|
|
|
-- createdAt:创建时间
|
|
|
-- name (配饰名称)
|
|
|
-- type (配饰类型,如项链、手表等)
|
|
|
-- material (配饰材质)
|
|
|
-- style (配饰风格)
|
|
|
-- recommendedFor (推荐给的用户,Pointer)
|
|
|
-
|
|
|
-#### Recommendation(穿搭推荐表)
|
|
|
-
|
|
|
-- objectId:唯一标识符
|
|
|
-- createdAt:创建时间
|
|
|
-- userProfile: Pointer (指向用户)
|
|
|
-- clothingItems: Array<Pointer> (推荐的服装)
|
|
|
-- accessoryItems: Array<Pointer> (推荐的配饰)
|
|
|
-### 2.PlantUML类图设计
|
|
|
-```plantuml
|
|
|
-@startuml
|
|
|
-class UserProfile {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +height: Float
|
|
|
- +weight: Float
|
|
|
- +age: Int
|
|
|
- +gender: String
|
|
|
- +occupation: String
|
|
|
- +preferences: String
|
|
|
- +weather: String
|
|
|
- +temperature: String
|
|
|
- +otherNeeds: String
|
|
|
-}
|
|
|
-
|
|
|
-class ClothingItem {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +name: String
|
|
|
- +type: String
|
|
|
- +size: String
|
|
|
- +color: String
|
|
|
- +style: String
|
|
|
- +recommendedFor: Pointer
|
|
|
-}
|
|
|
-
|
|
|
-class AccessoryItem {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +name: String
|
|
|
- +type: String
|
|
|
- +material: String
|
|
|
- +style: String
|
|
|
- +recommendedFor: Pointer
|
|
|
-}
|
|
|
-
|
|
|
-class Recommendation {
|
|
|
- +objectId: String
|
|
|
- +createdAt: Date
|
|
|
- +userProfile: Pointer
|
|
|
- +clothingItems: Array>
|
|
|
- +accessoryItems: Array>
|
|
|
-}
|
|
|
-
|
|
|
-UserProfile "1" -- "0..*" ClothingItem : contains
|
|
|
-UserProfile "1" -- "0..*" AccessoryItem : contains
|
|
|
-UserProfile "1" -- "0..*" Recommendation : makes
|
|
|
-@enduml
|
|
|
-```
|
|
|
-Language:plantuml
|
|
|
-### 3.设计说明
|
|
|
-UserProfile 表存储用户的基本信息和个性化需求。
|
|
|
-ClothingItem 和 AccessoryItem 表分别存储服装和配饰的信息,并通过 Pointer 关联到推荐的用户。
|
|
|
-Recommendation 表用于存储为特定用户生成的推荐,包括推荐的服装和配饰。
|
|
|
-这种设计符合第三范式(3NF),确保数据的规范化和减少冗余。
|
|
|
-
|
|
|
-# 二、业务逻辑描述
|
|
|
-## 个性化推荐的完整逻辑
|
|
|
-### 个性化推荐生成逻辑
|
|
|
-- 用户在APP内,通过文本生成穿搭推荐
|
|
|
- - 数据来源
|
|
|
- - 用户输入:用户的身高,体重,年龄,选择性别和输入补充信息(包括职业:非必填,喜好:非必填,天气:非必填,温度:非必填,其他需求:显高显瘦?儒雅甜美?等)
|
|
|
- - 用户体征:性别、年龄、体重等
|
|
|
- - 文本生成
|
|
|
- - 提示词:严格限制json格式,输出推荐的穿搭方案列表(附带当前时间,用于时间的生成)
|
|
|
- - 生成结果:recommendList
|
|
|
- - 循环数组,向Recommendation表逐个插入数据。
|
|
|
-```json
|
|
|
-
|
|
|
-[
|
|
|
- {
|
|
|
- "objectId": "rec1",
|
|
|
- "createdAt": "2024-12-09T22:00:00Z",
|
|
|
- "userProfile": "user1",
|
|
|
- "clothingItems": [
|
|
|
- "clothing1",
|
|
|
- "clothing2"
|
|
|
- ],
|
|
|
- "accessoryItems": [
|
|
|
- "accessory1",
|
|
|
- "accessory2"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "objectId": "rec2",
|
|
|
- "createdAt": "2024-12-09T22:00:00Z",
|
|
|
- "userProfile": "user2",
|
|
|
- "clothingItems": [
|
|
|
- "clothing3",
|
|
|
- "clothing4"
|
|
|
- ],
|
|
|
- "accessoryItems": [
|
|
|
- "accessory3"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "objectId": "rec3",
|
|
|
- "createdAt": "2024-12-09T22:00:00Z",
|
|
|
- "userProfile": "user3",
|
|
|
- "clothingItems": [
|
|
|
- "clothing5"
|
|
|
- ],
|
|
|
- "accessoryItems": [
|
|
|
- "accessory4",
|
|
|
- "accessory5"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "objectId": "rec4",
|
|
|
- "createdAt": "2024-12-09T22:00:00Z",
|
|
|
- "userProfile": "user4",
|
|
|
- "clothingItems": [
|
|
|
- "clothing6",
|
|
|
- "clothing7"
|
|
|
- ],
|
|
|
- "accessoryItems": []
|
|
|
- },
|
|
|
- {
|
|
|
- "objectId": "rec5",
|
|
|
- "createdAt": "2024-12-09T22:00:00Z",
|
|
|
- "userProfile": "user5",
|
|
|
- "clothingItems": [
|
|
|
- "clothing8"
|
|
|
- ],
|
|
|
- "accessoryItems": [
|
|
|
- "accessory6"
|
|
|
- ]
|
|
|
- }
|
|
|
-]
|
|
|
-```
|
|
|
-## 个性化推荐业务逻辑图例
|
|
|
-
|
|
|
-```plantuml
|
|
|
-@startuml
|
|
|
-actor User
|
|
|
-participant "APP" as App
|
|
|
-participant "Recommendation Service" as RecService
|
|
|
-participant "Recommendation Database" as RecDB
|
|
|
-
|
|
|
-User -> App: 输入身高、体重、年龄、性别等信息
|
|
|
-App -> RecService: 发送用户输入数据
|
|
|
-RecService -> RecService: 处理用户输入数据
|
|
|
-RecService -> RecService: 生成推荐穿搭方案
|
|
|
-RecService -> RecService: 准备推荐列表 (recommendList)
|
|
|
-
|
|
|
-loop 插入推荐数据
|
|
|
- RecService -> RecDB: 插入推荐数据
|
|
|
-end
|
|
|
-
|
|
|
-RecDB -> RecService: 返回插入结果
|
|
|
-RecService -> App: 返回推荐结果给用户
|
|
|
-App -> User: 显示推荐的穿搭方案列表
|
|
|
-@enduml
|
|
|
-```
|
|
|
-
|
|
|
-### 时序图说明
|
|
|
-1. **用户输入**: 用户在 APP 内输入身高、体重、年龄、性别等信息。
|
|
|
-2. **发送数据**: APP 将用户输入的数据发送给 Recommendation Service。
|
|
|
-3. **处理输入**: Recommendation Service 处理用户的输入数据。
|
|
|
-4. **生成推荐**: Recommendation Service 根据用户输入生成推荐穿搭方案。
|
|
|
-5. **准备推荐列表**: Recommendation Service 准备一个推荐列表(recommendList)。
|
|
|
-6. **插入推荐数据**: 通过循环,Recommendation Service 将推荐数据逐个插入到 Recommendation Database。
|
|
|
-7. **返回插入结果**: Recommendation Database 返回插入结果给 Recommendation Service。
|
|
|
-8. **返回推荐结果**: Recommendation Service 将推荐结果返回给 APP。
|
|
|
-9. **显示结果**: APP 显示推荐的穿搭方案列表给用户。
|
|
|
-
|
|
|
-这个时序图清晰地展示了个性化推荐生成逻辑的每一步,描述了用户与系统之间的交互过程。
|