This commit is contained in:
toom1996
2026-09-02 21:51:35 +08:00
parent 2562fc4aaa
commit 1fd9c48f58
22 changed files with 908 additions and 30 deletions

View File

@ -0,0 +1,17 @@
-- 007: favorites —— 用户收藏(服务端持久化,按用户隔离)
-- 与项目约定一致:表结构由 SQL 托管,不依赖 GORM AutoMigrate。
-- target_uid 存前端卡片的 it.id(编码串),与前端直接对齐;title/cover/brand 为收藏时快照。
CREATE TABLE IF NOT EXISTS `favorites` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`created_at` int unsigned NOT NULL DEFAULT 0,
`user_id` int unsigned NOT NULL,
`target_type` varchar(16) NOT NULL DEFAULT '',
`target_uid` varchar(64) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`cover` varchar(512) NOT NULL DEFAULT '',
`brand` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_user_target` (`user_id`, `target_uid`),
KEY `idx_user` (`user_id`),
KEY `idx_user_created` (`user_id`, `created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;