Add user profile management for smoking data
- Introduced new API endpoints `GET /api/v1/smoke/profile` and `PUT /api/v1/smoke/profile` for retrieving and updating user smoking profiles. - Added a new database table `fa_smoke_user_profile` to store user-specific smoking data, including daily smoking habits and motivations. - Updated the smoke handler and service to integrate user profile data into AI advice generation. - Enhanced documentation to reflect the new user profile features and their usage.
This commit is contained in:
@@ -54,3 +54,26 @@ CREATE TABLE IF NOT EXISTS `fa_smoke_ai_advice_unlocks` (
|
||||
UNIQUE KEY `uniq_smoke_ai_unlock` (`uid`,`unlock_date`),
|
||||
KEY `idx_smoke_ai_unlock_uid_date` (`uid`,`unlock_date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='AI戒烟建议-广告解锁';
|
||||
|
||||
-- 用户基础信息(首次进入补全,用于基准/AI/看板公式等)
|
||||
-- 说明:
|
||||
-- - 使用 GORM 默认 created_at/updated_at/deleted_at(datetime(3))
|
||||
-- - smoke_motivations/quit_motivations 建议存 JSON 数组(例如 ["压力大","社交"])
|
||||
CREATE TABLE IF NOT EXISTS `fa_smoke_user_profile` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`created_at` datetime(3) NULL DEFAULT NULL,
|
||||
`updated_at` datetime(3) NULL DEFAULT NULL,
|
||||
`deleted_at` datetime(3) NULL DEFAULT NULL,
|
||||
`uid` int NOT NULL COMMENT '用户ID',
|
||||
`baseline_cigs_per_day` int NOT NULL DEFAULT 0 COMMENT '基础烟量(日均抽烟支数)',
|
||||
`smoking_years` decimal(6,2) NOT NULL DEFAULT 0.00 COMMENT '烟龄(年)',
|
||||
`pack_price_cent` int NOT NULL DEFAULT 0 COMMENT '单包价格(分)',
|
||||
`smoke_motivations` json DEFAULT NULL COMMENT '抽烟动机(JSON数组)',
|
||||
`quit_motivations` json DEFAULT NULL COMMENT '戒烟动力(JSON数组)',
|
||||
`wake_up_time` varchar(5) NOT NULL DEFAULT '' COMMENT '起床时间(HH:MM)',
|
||||
`sleep_time` varchar(5) NOT NULL DEFAULT '' COMMENT '入睡时间(HH:MM)',
|
||||
`onboarding_completed_at` datetime(3) DEFAULT NULL COMMENT '首次补全完成时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_smoke_profile_uid` (`uid`),
|
||||
KEY `idx_smoke_profile_deleted_at` (`deleted_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='戒烟-用户基础信息';
|
||||
|
||||
Reference in New Issue
Block a user