Documentation
¶
Index ¶
Constants ¶
View Source
const ( SubjectTopic = "Topic" SubjectPost = "Post" SubjectUser = "User" )
SubjectType 目标对象类型
Variables ¶
This section is empty.
Functions ¶
func Record ¶
func Record(userId uint64, action ActionType, subjectType string, subjectId uint64, preview string) error
Record 记录一条用户行为
func RecordWithTime ¶
func RecordWithTime(userId uint64, action ActionType, subjectType string, subjectId uint64, preview string, t time.Time) error
RecordWithTime 记录一条带有指定时间的用户行为(用于数据修复)
Types ¶
type ActionType ¶
type ActionType int
ActionType 行为类型枚举
const ( ActionSignUp ActionType = 1 // 注册帐号 ActionPost ActionType = 2 // 发帖/发布话题 ActionLike ActionType = 3 // 点赞 ActionFollow ActionType = 4 // 关注 ActionComment ActionType = 5 // 回复/评论 )
type Entity ¶
type Entity struct {
Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"` // 主键
UserId uint64 `gorm:"column:user_id;type:bigint unsigned;not null;default:0;index:idx_user_activity_created;" json:"userId"` // 发起者 ID
Action int `gorm:"column:action;type:int;not null;default:0;" json:"action"` // 行为类型
SubjectType string `gorm:"column:subject_type;type:varchar(32);not null;default:'';" json:"subjectType"` // 目标类型
SubjectId uint64 `gorm:"column:subject_id;type:bigint unsigned;not null;default:0;" json:"subjectId"` // 目标 ID
ContentPreview string `gorm:"column:content_preview;type:text;" json:"contentPreview"` // 内容摘要
CreatedAt time.Time `gorm:"column:created_at;index;autoCreateTime;index:idx_user_activity_created;" json:"createdAt"` //
}
func GetUserTimeline ¶
GetUserTimeline 获取用户的动态时间轴(基于主键的分页)
Click to show internal directories.
Click to hide internal directories.