53 lines
1.9 KiB
Go
53 lines
1.9 KiB
Go
package model
|
||
|
||
import (
|
||
"admin/internal/consts"
|
||
"admin/internal/db"
|
||
"admin/internal/model/dto"
|
||
"database/sql"
|
||
"time"
|
||
)
|
||
|
||
func init() {
|
||
db.RegisterTableModels(CDKey{})
|
||
}
|
||
|
||
type CDKey struct {
|
||
ID int `gorm:"primarykey" readonly:"true"`
|
||
ProjectId int `gorm:"uniqueIndex:idx_project_cdkey"`
|
||
ServerIDs []string `gorm:"type:json;serializer:json" name:"区服" desc:"不选就是全服通用" type:"[]string" choices:"GetChoiceServers" multi_choice:"true" uneditable:"true""`
|
||
Name string `gorm:"type:varchar(100);uniqueIndex:idx_project_cdkey" name:"礼包说明" required:"true" uneditable:"true"`
|
||
CodeType int `name:"礼包类型" required:"true" choices:"GetCodeTypeChoices" uneditable:"true"`
|
||
Code string `gorm:"type:VARCHAR(50);index" name:"礼包码" desc:"一码通用才配置" uneditable:"true"`
|
||
CodeNum int `name:"礼包数量" desc:"一码一用才配置,最大礼包数量10万个"`
|
||
ValidStartTime sql.NullTime `name:"生效起始时间"`
|
||
ValidEndTime sql.NullTime `name:"生效结束时间"`
|
||
Attach []*MailAttachItem `gorm:"type:json;serializer:json" name:"礼包码奖励道具" type:"items" desc:"搜索道具并点击添加"`
|
||
|
||
CreatedAt time.Time `readonly:"true"`
|
||
UpdatedAt time.Time `readonly:"true"`
|
||
}
|
||
|
||
func (lm *CDKey) TableName() string {
|
||
return "cdkey"
|
||
}
|
||
|
||
func (m *CDKey) GetId() int {
|
||
return m.ID
|
||
}
|
||
|
||
func (m *CDKey) GetShowKey() string {
|
||
return m.Name
|
||
}
|
||
|
||
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)
|
||
}
|