package model

import "time"

// 域能流水类型常量
const (
	EnergyTypeSignIn      = "sign_in"
	EnergyTypeRename      = "rename"
	EnergyTypeRenameRefund = "rename_refund"
	EnergyTypeEnergize    = "energize"
	EnergyTypeEnergized   = "energized"
	EnergyTypeDeletePost  = "delete_post"
	EnergyTypeAdminAdjust = "admin_adjust"
)

// EnergyLog 域能流水记录
type EnergyLog struct {
	ID          uint      `gorm:"primarykey" json:"id"`
	UserID      uint      `gorm:"index;not null" json:"user_id"`
	Amount      int       `gorm:"not null" json:"amount"`                   // 变化量（乘10，正为增加，负为扣减）
	Type        string    `gorm:"type:varchar(30);index;not null" json:"type"` // sign_in/rename/rename_refund/energize/energized/delete_post/admin_adjust
	RelatedType string    `gorm:"type:varchar(30);default:''" json:"related_type,omitempty"`
	RelatedID   uint      `gorm:"default:0" json:"related_id,omitempty"`
	Description string    `gorm:"type:varchar(500);default:''" json:"description,omitempty"`
	OperatorUID *uint     `gorm:"default:null" json:"operator_uid,omitempty"` // 操作者UID（后台操作时必填）
	CreatedAt   time.Time `json:"created_at"`
}

// EnergyLogDisplayNames 流水类型 → 中文名
var EnergyLogDisplayNames = map[string]string{
	EnergyTypeSignIn:      "每日签到",
	EnergyTypeRename:      "改名消耗",
	EnergyTypeRenameRefund: "改名退款",
	EnergyTypeEnergize:    "赋能消耗",
	EnergyTypeEnergized:   "被赋能",
	EnergyTypeDeletePost:  "删稿消耗",
	EnergyTypeAdminAdjust: "后台调整",
}
