2025-05-08 15:48:34 +08:00

48 lines
1.7 KiB
Go

package model
import (
"admin/apps/game/model/dto"
"admin/internal/consts"
"admin/internal/db"
"database/sql"
"time"
)
func init() {
db.RegisterTableModels(CDKey{})
}
type CDKey struct {
ID int `gorm:"primarykey" readonly:"true"`
ProjectId int `gorm:"index:idx_project_id"`
Name string `gorm:"type:varchar(100);unique" name:"礼包说明" required:"true" uneditable:"true"`
ServerIDs []string `gorm:"type:json;serializer:json" name:"区服" desc:"不选就是全服通用" type:"[]string" choices:"GetChoiceServers" multi_choice:"true" uneditable:"true""`
CodeType int `name:"礼包类型" required:"true" choices:"GetCodeTypeChoices" uneditable:"true"`
Code string `gorm:"type:VARCHAR(50);index" name:"礼包码" desc:"一码通用才配置"`
CodeNum int `name:"礼包数量" desc:"一码一用才配置"`
ValidStartTime sql.NullTime `name:"生效起始时间"`
ValidEndTime sql.NullTime `name:"生效结束时间"`
Attach []*MailAttachItem `gorm:"type:json;serializer:json" name:"礼包码奖励道具" type:"items" desc:"搜索道具并点击添加"`
CreatedAt time.Time `readonly:"true"`
}
func (lm *CDKey) TableName() string {
return "cdkey"
}
func (m *CDKey) GetId() int {
return m.ID
}
func (m *CDKey) GetCodeTypeChoices(project *Project) []*dto.CommonDtoFieldChoice {
return []*dto.CommonDtoFieldChoice{
{Desc: "一码通用", Value: consts.CDKeyType_Global},
{Desc: "一码一用", Value: consts.CDKeyType_Private},
}
}
func (m *CDKey) GetChoiceServers(project *Project) []*dto.CommonDtoFieldChoice {
return getChoiceServers(project)
}