49 lines
1.8 KiB
Go
Raw Normal View History

2025-05-07 15:03:19 +08:00
package model
import (
2025-05-07 18:25:31 +08:00
"admin/internal/consts"
2025-05-07 15:03:19 +08:00
"admin/internal/db"
2025-05-16 15:17:10 +08:00
"admin/internal/model/dto"
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"`
2025-05-15 17:30:33 +08:00
ProjectId int `gorm:"uniqueIndex:idx_project_cdkey"`
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-15 17:30:33 +08:00
Name string `gorm:"type:varchar(100);uniqueIndex:idx_project_cdkey" 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-16 18:04:52 +08:00
CodeNum int `name:"礼包数量" desc:"一码一用才配置最大礼包数量10万个"`
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"`
2025-05-15 17:30:33 +08:00
UpdatedAt time.Time `readonly:"true"`
2025-05-07 15:03:19 +08:00
}
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)
}