update
This commit is contained in:
20
internal/model/favorite.go
Normal file
20
internal/model/favorite.go
Normal 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" }
|
||||
19
internal/model/history.go
Normal file
19
internal/model/history.go
Normal file
@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
// History 用户浏览历史(服务端持久化,按用户隔离,跨设备一致)。
|
||||
//
|
||||
// 2026-09-02 收敛为「文章级」记录:点开某篇走秀/街拍详情(/item/xxx)时记一条,
|
||||
// 进入列表页不再记。仅存三要素:user_id + target_uid + viewed_at。
|
||||
// target_uid 为带类型前缀的对外编码串(runway r=xxx / street s=xxx,见 hashid.EncodeTyped),
|
||||
// 前缀本身携带类型,无需 kind / target_type 列;title/cover/brand 快照也已移除,
|
||||
// 账户页展示时按 target_uid 回查公开详情接口(保持表最简、数据新鲜)。
|
||||
// 唯一键 (user_id, target_uid) 保证同一篇文章反复打开只刷新 viewed_at、不新增行。
|
||||
type History struct {
|
||||
ID uint32 `gorm:"primaryKey;column:id" json:"id"`
|
||||
ViewedAt uint32 `gorm:"column:viewed_at" json:"viewed_at"`
|
||||
UserID uint32 `gorm:"column:user_id;not null" json:"user_id"`
|
||||
TargetUID string `gorm:"column:target_uid;size:64;not null;uniqueIndex:uniq_user_target" json:"target_uid"`
|
||||
}
|
||||
|
||||
// TableName 指定表名。
|
||||
func (History) TableName() string { return "histories" }
|
||||
Reference in New Issue
Block a user