uniugm/admin/apps/game/model/whitelist.go

46 lines
1.3 KiB
Go

package model
import (
"admin/internal/db"
"admin/internal/model/dto"
"time"
)
func init() {
db.RegisterTableModels(WhiteList{})
}
type WhiteList struct {
ID int `gorm:"primarykey" readonly:"true"`
ProjectId int `gorm:"uniqueIndex:idx_whitelist"`
ServerConfID []string `gorm:"type:json;serializer:json" type:"[]string" name:"区服id" desc:"不选就是默认所有区服" choices:"GetChoiceServers" multi_choice:"true" where:"eq"`
WType string `name:"白名单类型" desc:"账号或者ip" required:"true" choices:"GetWhitelistTypeChoices"`
Value string `gorm:"type:varchar(128);uniqueIndex:idx_whitelist" name:"账号或者ip等值" required:"true"`
CreatedAt time.Time `readonly:"true" where:"range"`
UpdatedAt time.Time `readonly:"true"`
}
func (lm *WhiteList) TableName() string {
return "whitelist"
}
func (m *WhiteList) GetId() int {
return m.ID
}
func (m *WhiteList) GetShowKey() string {
return m.Value
}
func (m *WhiteList) GetChoiceServers(project *Project) []*dto.CommonDtoFieldChoice {
return getChoiceServers(project)
}
func (m *WhiteList) GetWhitelistTypeChoices(project *Project) []*dto.CommonDtoFieldChoice {
return []*dto.CommonDtoFieldChoice{
{Desc: "IP", Value: "ip"},
{Desc: "账号", Value: "account"},
}
}