feat: 支持用户自定义食物
This commit is contained in:
26
sql-scripts/user-custom-foods-table.sql
Normal file
26
sql-scripts/user-custom-foods-table.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- 创建用户自定义食物表
|
||||
-- 该表用于存储用户自定义添加的食物信息
|
||||
CREATE TABLE IF NOT EXISTS `t_user_custom_foods` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`user_id` varchar(255) NOT NULL COMMENT '用户ID',
|
||||
`name` varchar(100) NOT NULL COMMENT '食物名称',
|
||||
`description` varchar(500) DEFAULT NULL COMMENT '食物描述',
|
||||
`calories_per_100g` float DEFAULT NULL COMMENT '每100克热量(卡路里)',
|
||||
`protein_per_100g` float DEFAULT NULL COMMENT '每100克蛋白质含量(克)',
|
||||
`carbohydrate_per_100g` float DEFAULT NULL COMMENT '每100克碳水化合物含量(克)',
|
||||
`fat_per_100g` float DEFAULT NULL COMMENT '每100克脂肪含量(克)',
|
||||
`fiber_per_100g` float DEFAULT NULL COMMENT '每100克膳食纤维含量(克)',
|
||||
`sugar_per_100g` float DEFAULT NULL COMMENT '每100克糖分含量(克)',
|
||||
`sodium_per_100g` float DEFAULT NULL COMMENT '每100克钠含量(毫克)',
|
||||
`additional_nutrition` json DEFAULT NULL COMMENT '其他营养信息(维生素、矿物质等)',
|
||||
`image_url` varchar(500) DEFAULT NULL COMMENT '食物图片URL',
|
||||
`sort_order` int NOT NULL DEFAULT '0' COMMENT '排序(分类内)',
|
||||
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_user_id` (`user_id`),
|
||||
KEY `idx_category_key` (`category_key`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_user_category_sort` (`user_id`, `category_key`, `sort_order`),
|
||||
CONSTRAINT `fk_user_custom_food_category` FOREIGN KEY (`category_key`) REFERENCES `t_food_categories` (`key`) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户自定义食物表';
|
||||
Reference in New Issue
Block a user