articlesUserStat

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecrementUserReply

func DecrementUserReply(articleId, userId uint64) error

DecrementUserReply 减少评论计数 (用于删除评论)

func FixStat

func FixStat(articleId, userId uint64, count uint32, lastReplyAt time.Time) error

func IncrementUserReply

func IncrementUserReply(articleId, userId uint64) error

IncrementUserReply 增加评论计数

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

func SyncArticlePosters

func SyncArticlePosters(articleId uint64) []uint64

SyncArticlePosters 重新计算并刷新文章表的头像 JSON

Types

type Entity

type Entity struct {
	Id uint64 `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"`
	// 联合唯一索引 idx_article_user 用于 Upsert (On Conflict) 定位
	// 联合索引 idx_active_query 用于高性能获取前 5 名活跃用户
	ArticleId uint64 `` /* 145-byte string literal not displayed */
	UserId    uint64 `gorm:"column:user_id;type:bigint unsigned;not null;uniqueIndex:idx_article_user,priority:2" json:"userId"`

	// 计数器和时间,用于排序
	ReplyCount  uint32    `gorm:"column:reply_count;type:int unsigned;not null;default:0;index:idx_active_query,priority:2" json:"replyCount"`
	LastReplyAt time.Time `` /* 129-byte string literal not displayed */

	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime;<-:create;" json:"createdAt"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;" json:"updatedAt"`
}

func Get

func Get(id any) (entity Entity)

func (*Entity) TableName

func (itself *Entity) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL