mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
dev day #79
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/datatypes"
|
||||
|
||||
// PointsTransaction logs changes in points/xp
|
||||
// Reason examples: comment_create, poll_vote, newsletter_subscribe, redeem, admin_adjust
|
||||
// Meta can hold ids like {"comment_id":123}
|
||||
|
||||
type PointsTransaction struct {
|
||||
BaseModel
|
||||
UserID uint `json:"user_id" gorm:"index;not null"`
|
||||
Delta int64 `json:"delta"`
|
||||
XPDelta int64 `json:"xp_delta"`
|
||||
Reason string `json:"reason" gorm:"size:64;index"`
|
||||
Meta datatypes.JSONMap `json:"meta" gorm:"type:jsonb"`
|
||||
}
|
||||
|
||||
func (PointsTransaction) TableName() string { return "points_transactions" }
|
||||
|
||||
// Achievement definition managed in DB for flexibility
|
||||
// Condition is a code string handled by service (e.g., first_comment, first_vote, votes_10, comments_25)
|
||||
|
||||
type Achievement struct {
|
||||
BaseModel
|
||||
Code string `json:"code" gorm:"size:64;uniqueIndex"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Points int64 `json:"points"`
|
||||
XP int64 `json:"xp"`
|
||||
Icon string `json:"icon"`
|
||||
Active bool `json:"active" gorm:"default:true"`
|
||||
}
|
||||
|
||||
func (Achievement) TableName() string { return "achievements" }
|
||||
|
||||
type UserAchievement struct {
|
||||
BaseModel
|
||||
UserID uint `json:"user_id" gorm:"index;not null"`
|
||||
AchievementID uint `json:"achievement_id" gorm:"index;not null"`
|
||||
}
|
||||
|
||||
func (UserAchievement) TableName() string { return "user_achievements" }
|
||||
|
||||
// Reward items configured by admin (e.g., avatars, merch vouchers)
|
||||
|
||||
type RewardItem struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type" gorm:"size:32;index"` // avatar_static, avatar_animated, merch_coupon, custom
|
||||
CostPoints int64 `json:"cost_points"`
|
||||
ImageURL string `json:"image_url"`
|
||||
Stock int `json:"stock"`
|
||||
Active bool `json:"active" gorm:"default:true"`
|
||||
Metadata datatypes.JSONMap `json:"metadata" gorm:"type:jsonb"`
|
||||
}
|
||||
|
||||
func (RewardItem) TableName() string { return "reward_items" }
|
||||
|
||||
// Redemption log for rewards
|
||||
|
||||
type RewardRedemption struct {
|
||||
BaseModel
|
||||
UserID uint `json:"user_id" gorm:"index;not null"`
|
||||
RewardID uint `json:"reward_id" gorm:"index;not null"`
|
||||
Status string `json:"status" gorm:"size:24;default:'pending';index"`
|
||||
}
|
||||
|
||||
func (RewardRedemption) TableName() string { return "reward_redemptions" }
|
||||
Reference in New Issue
Block a user