Files
backend_v2/internal/model/favorite.go
toom1996 1fd9c48f58 update
2026-09-02 21:51:35 +08:00

21 lines
1.1 KiB
Go
Raw 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.

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" }