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,20 @@
package model
// Favorite 用户收藏(服务端持久化,按用户隔离)。
//
// 存储「对外编码 uid」(如 runway 的 r= 前缀串、street 的 s= 前缀串)而非数字主键,
// 这样无需 decode 即可与前端卡片的 it.id 直接对齐,取消收藏时也只靠该串匹配。
// title / cover / brand 为收藏时的快照,供个人中心直接渲染,不必回查原表。
type Favorite struct {
ID uint32 `gorm:"primaryKey;column:id" json:"id"`
CreatedAt uint32 `gorm:"column:created_at" json:"created_at"`
UserID uint32 `gorm:"column:user_id;index:idx_user;not null" json:"user_id"`
TargetType string `gorm:"column:target_type;size:16;not null" json:"target_type"` // runway | street
TargetUID string `gorm:"column:target_uid;size:64;not null;uniqueIndex:uniq_user_target" json:"target_uid"`
Title string `gorm:"column:title;size:255" json:"title"`
Cover string `gorm:"column:cover;size:512" json:"cover"`
Brand string `gorm:"column:brand;size:255" json:"brand"`
}
// TableName 指定表名。
func (Favorite) TableName() string { return "favorites" }