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