Files
plates-server/sql-scripts/user-food-favorites-table-create.sql
richarjiang d0b02b6228 feat: 新增用户食物收藏功能
- 创建用户食物收藏表 `t_user_food_favorites`,用于存储用户收藏的食物信息。
- 在 `FoodLibraryController` 中添加收藏和取消收藏食物的 API 接口。
- 在 `FoodLibraryService` 中实现收藏和取消收藏的业务逻辑,并获取用户收藏的食物 ID 列表。
- 更新 DTO 以支持食物是否已收藏的状态。
2025-08-29 21:03:55 +08:00

14 lines
852 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 用户食物收藏表
CREATE TABLE IF NOT EXISTS `t_user_food_favorites` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` VARCHAR(255) NOT NULL COMMENT '用户ID',
`food_id` BIGINT NOT NULL COMMENT '食物ID',
`food_type` ENUM('system', 'custom') NOT NULL DEFAULT 'system' COMMENT '食物类型system: 系统食物, custom: 用户自定义食物)',
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_food` (`user_id`, `food_id`, `food_type`),
KEY `idx_user_id` (`user_id`),
KEY `idx_food_id` (`food_id`),
KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户食物收藏表';