package model import ( "time" "spark-server/internal/module/energy/entity" ) // WalletRow maps t_user_wallets. type WalletRow struct { UserID int64 `gorm:"column:user_id;primaryKey"` Energy int64 `gorm:"column:energy"` UpdatedAt time.Time `gorm:"column:updated_at"` } func (WalletRow) TableName() string { return "t_user_wallets" } func (r WalletRow) Entity() *entity.Wallet { return &entity.Wallet{UserID: r.UserID, Energy: r.Energy, UpdatedMS: r.UpdatedAt.UnixMilli()} } // SignRow maps t_sign_records. type SignRow struct { ID int64 `gorm:"column:id;primaryKey;autoIncrement"` UserID int64 `gorm:"column:user_id"` DayKey int `gorm:"column:day_key"` Kind int16 `gorm:"column:kind"` Reward int `gorm:"column:reward"` CreatedAt time.Time `gorm:"column:created_at"` } func (SignRow) TableName() string { return "t_sign_records" } func (r SignRow) Entity() *entity.SignRecord { return &entity.SignRecord{ ID: r.ID, UserID: r.UserID, DayKey: r.DayKey, Kind: r.Kind, Reward: r.Reward, CreatedMS: r.CreatedAt.UnixMilli(), } } func signFromEntity(e *entity.SignRecord) *SignRow { return &SignRow{ ID: e.ID, UserID: e.UserID, DayKey: e.DayKey, Kind: e.Kind, Reward: e.Reward, CreatedAt: time.UnixMilli(e.CreatedMS), } } // EnergyLogRow maps t_energy_logs. type EnergyLogRow struct { ID int64 `gorm:"column:id;primaryKey;autoIncrement"` UserID int64 `gorm:"column:user_id"` Delta int64 `gorm:"column:delta"` BalanceAfter int64 `gorm:"column:balance_after"` Reason string `gorm:"column:reason"` DayKey int `gorm:"column:day_key"` Source string `gorm:"column:source"` CreatedAt time.Time `gorm:"column:created_at"` } func (EnergyLogRow) TableName() string { return "t_energy_logs" } func (r EnergyLogRow) Entity() *entity.EnergyLog { return &entity.EnergyLog{ ID: r.ID, UserID: r.UserID, Delta: r.Delta, BalanceAfter: r.BalanceAfter, Reason: r.Reason, DayKey: r.DayKey, Source: r.Source, CreatedMS: r.CreatedAt.UnixMilli(), } }