|
1 周之前 | |
---|---|---|
.. | ||
page-detail | 1 周之前 | |
page-selectlist | 1 周之前 | |
page-type | 1 周之前 | |
README.md | 1 周之前 | |
tab1-routing.module.ts | 1 周之前 | |
tab1.module.ts | 2 周之前 | |
tab1.page.html | 1 周之前 | |
tab1.page.scss | 1 周之前 | |
tab1.page.spec.ts | 1 月之前 | |
tab1.page.ts | 1 周之前 |
#AI智能食谱推荐助手
#数据范式设计
您是一名专业的数据库工程师,熟悉PostgreSQL数据库和ParseServer,请注意表名用大驼峰,字段小驼峰,有预留字段:objectId,updatedAt,createdAt。 关于ParseServer中断 数据类的描述,字段主要类型有 String => String Number => Number Bool => bool Array => JSON Array Object => JSON Object Date => Date File => Parse.File Pointer => other Parse.Object Relation => Parse.Relation Null => null GeoPoint => {latitude: 40.0, longitude: -30.0}
#项目需求 我需要一个食谱推荐系统,需要有食谱表,食谱分类表(中式菜系,西式料理,减脂轻食,甜点烘培,汤羹粥品,素食主义),每日推荐(每日推荐3个)
#UML类图
@startuml
' 设置全局样式
skinparam class {
BackgroundColor White
ArrowColor #444444
BorderColor #444444
}
hide circle
' 实体定义
class Recipe {
objectId: String
createdAt: Date
updatedAt: Date
title: String
imageUrl: String
prepTime: String
cookTime: String
difficulty: String
servings: Number
ingredients: JSON Array
steps: JSON Array
rating: Number
viewCount: Number
category: Pointer<RecipeCategory>
author: Pointer<_User>
}
class RecipeCategory {
objectId: String
createdAt: Date
updatedAt: Date
name: String
icon: String
sortOrder: Number
}
class DailyRecommendation {
objectId: String
createdAt: Date
updatedAt: Date
date: Date
recommendedRecipes: Array<Pointer<Recipe>>
algorithmVersion: String
}
class RecipeHistory {
objectId: String
createdAt: Date
updatedAt: Date
user: Pointer<_User>
recipe: Pointer<Recipe>
viewCount: Number
lastViewedAt: Date
}
class RecipeFavorite {
objectId: String
createdAt: Date
updatedAt: Date
user: Pointer<_User>
recipe: Pointer<Recipe>
tags: Array<String>
}
class UserPreference {
objectId: String
createdAt: Date
updatedAt: Date
user: Pointer<_User>
preferredCategories: Array<Pointer<RecipeCategory>>
dietaryRestrictions: Array<String>
calorieRange: Object
}
' 系统内置用户表
class _User {
objectId: String
username: String
email: String
createdAt: Date
updatedAt: Date
}
' 关系定义
RecipeCategory ||--o{ Recipe : "1个分类 → 多个食谱"
DailyRecommendation }o--|| Recipe : "每日推荐 → 多个食谱"
Recipe ||--o| _User : "作者关系"
_User ||--o{ RecipeHistory : "浏览历史"
_User ||--o{ RecipeFavorite : "收藏记录"
_User ||--o| UserPreference : "用户偏好"
Recipe ||--o{ RecipeHistory : "被浏览记录"
Recipe ||--o{ RecipeFavorite : "被收藏记录"
' 样式调整
note top of Recipe
**新增字段**
viewCount: 浏览量统计
**索引建议**
(category) 索引
(rating) 索引
(createdAt) 索引
end note
note left of RecipeHistory
**索引建议**
复合索引(user, recipe)
(lastViewedAt) 索引
**约束**
自动更新viewCount
end note
note right of RecipeFavorite
**索引建议**
复合唯一索引(user, recipe)
(createdAt) 索引
**功能**
支持标签分类收藏
end note
note bottom of UserPreference
**数据结构**
calorieRange: {
min: Number,
max: Number
}
**索引建议**
(user) 唯一索引
end note
@enduml
这个设计包含以下核心要素:
通过Pointer关联分类和作者
RecipeCategory(分类表)
预置6大分类类型
通过icon字段支持前端图标展示
DailyRecommendation(每日推荐表)
按日期存储推荐记录
使用Pointer数组关联当日推荐的3个食谱
扩展性设计
内置用户系统(_User表)支持用户相关功能扩展
评分字段为推荐算法留出扩展空间
通过云函数可实现智能推荐逻辑
建议配合Parse Server的afterSave云函数实现: