Files
backend_v2/internal/model/history.go
toom1996 7dd3fda73c update
2026-09-16 00:56:15 +08:00

20 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
// History 用户浏览历史(服务端持久化,按用户隔离,跨设备一致)。
//
// 2026-09-02 收敛为「文章级」记录:点开某篇走秀/街拍详情(/item/xxx)时记一条,
// 进入列表页不再记。仅存三要素:user_id + target_uid + viewed_at。
// target_uid 为对外编码串(类型进密码、无前缀,见 hashid.EncodeWithType);类型由账户页
// 存储的 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" }