feat(admin): 独立后台壳、站点分析与聊天监管,公开站拆出主题切换与访问埋点

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 04:00:14 +08:00
parent cda5fad2e5
commit 9a55c2f6f2
41 changed files with 5655 additions and 1810 deletions

View File

@@ -37,7 +37,7 @@ func InitDB(dsn string) error {
if err := db.AutoMigrate(
&User{}, &Board{}, &Post{}, &Comment{}, &CommentEditHistory{}, &RefreshToken{}, &Like{}, &Notification{}, &Checkin{},
&Announcement{}, &SiteSetting{}, &Attachment{}, &UserBoard{}, &LoginLog{},
&Announcement{}, &SiteSetting{}, &SiteDailyStats{}, &SiteDailyVisitor{}, &Attachment{}, &UserBoard{}, &LoginLog{},
&ChatRoom{}, &ChatRoomMember{}, &ChatMessage{},
&PointLedger{}, &PostContentUnlock{}, &PostAttachment{}, &PostAttachmentUnlock{},
&PostPollVote{}, &PostLotteryEntry{},

View File

@@ -400,6 +400,21 @@ type SiteSetting struct {
UpdatedAt time.Time `json:"updated_at"`
}
// SiteDailyStats 站点日维度访问量(轻量 PV/UV)
type SiteDailyStats struct {
Date time.Time `gorm:"type:date;primaryKey" json:"date"`
PV int64 `gorm:"not null;default:0" json:"pv"`
UV int64 `gorm:"not null;default:0" json:"uv"`
LoggedInPV int64 `gorm:"not null;default:0" json:"logged_in_pv"`
UpdatedAt time.Time `json:"updated_at"`
}
// SiteDailyVisitor 当日访客去重(vid 哈希);插入成功才给 UV +1
type SiteDailyVisitor struct {
Date time.Time `gorm:"type:date;primaryKey" json:"date"`
VidHash string `gorm:"size:64;primaryKey" json:"-"`
}
// 附件类型
const (
AttachmentKindAvatar = "avatar" // 用户头像(正方形 WebP)