CuddleNan 5e8a1eebbf 改图片路径 1 周之前
..
page-detail 5e8a1eebbf 改图片路径 1 周之前
page-selectlist 5e8a1eebbf 改图片路径 1 周之前
page-type 06d6eb1ba9 解决对话和编辑问题 1 周之前
README.md 4af08d5557 页面跳转 1 周之前
tab1-routing.module.ts 06d6eb1ba9 解决对话和编辑问题 1 周之前
tab1.module.ts 6df1fcb41d 跳转 2 周之前
tab1.page.html 5e8a1eebbf 改图片路径 1 周之前
tab1.page.scss 9e11f51465 食谱检索 1 周之前
tab1.page.spec.ts 3795c5f682 tab1-1.0 1 月之前
tab1.page.ts 06d6eb1ba9 解决对话和编辑问题 1 周之前

README.md

#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

这个设计包含以下核心要素:

  1. Recipe(食谱主表)
  2. 包含详细的食谱元数据(烹饪时间、难度等)
  3. 使用JSON Array存储结构化数据(食材列表和步骤说明)
  4. 通过Pointer关联分类和作者

  5. RecipeCategory(分类表)

  6. 预置6大分类类型

  7. 通过icon字段支持前端图标展示

  8. DailyRecommendation(每日推荐表)

  9. 按日期存储推荐记录

  10. 使用Pointer数组关联当日推荐的3个食谱

  11. 扩展性设计

  12. 内置用户系统(_User表)支持用户相关功能扩展

  13. 评分字段为推荐算法留出扩展空间

  14. 通过云函数可实现智能推荐逻辑

建议配合Parse Server的afterSave云函数实现:

  • 每日定时生成推荐
  • 自动维护推荐关联
  • 评分自动更新等业务逻辑 ``` 创建测试数据 导入数据