package model import ( "admin/apps/game/model/dto" "admin/internal/consts" "admin/internal/db" "database/sql" "time" ) func init() { db.RegisterTableModels(Ban{}) } type Ban struct { ID int `gorm:"primarykey" readonly:"true"` ProjectId int `gorm:"index:project_id"` ServerConfID string `gorm:"type:varchar(200);index:idx_server" name:"区服id" required:"true" choices:"GetServerConfIDChoices" uneditable:"true" where:"eq"` BanType string `name:"封禁类型" required:"true" choices:"GetBanTypeChoices" uneditable:"true" where:"eq"` Value string `gorm:"type:varchar(128);index:value" name:"封禁值" required:"true" desc:"根据封禁类型填对应值,例如ip就填ip地址" uneditable:"true" where:"eq"` BanReason string `name:"封禁描述" desc:"封禁描述,入库记录的描述信息" required:"true"` BanNotifyReason string `name:"封禁弹窗" desc:"封禁弹窗内容,会推送给客户端弹窗" required:"true"` ExpireAt sql.NullTime `name:"封禁到期时间" desc:"封禁到期时间,0表示永久封禁"` CreatedAt time.Time `readonly:"true"` } func (lm *Ban) TableName() string { return "ban" } func (m *Ban) GetId() int { return m.ID } func (m *Ban) GetServerConfIDChoices(project *Project) []*dto.CommonDtoFieldChoice { return getChoiceServers(project) } func (m *Ban) GetBanTypeChoices(project *Project) []*dto.CommonDtoFieldChoice { switch project.ProjectType { case consts.RegisteredProjectId_shenmodalu: return []*dto.CommonDtoFieldChoice{ //{ // Desc: "账号", // Value: consts.BanType_Account, //}, //{ // Desc: "IP", // Value: consts.BanType_Ip, //}, { Desc: "角色登录", Value: consts.BanType_Role, }, { Desc: "角色发言", Value: consts.BanType_RoleChat, }, } } return []*dto.CommonDtoFieldChoice{ { Desc: "账号", Value: consts.BanType_Account, }, { Desc: "角色登录", Value: consts.BanType_Role, }, { Desc: "IP", Value: consts.BanType_Ip, }, { Desc: "账号发言", Value: consts.BanType_AccountChat, }, { Desc: "角色发言", Value: consts.BanType_RoleChat, }, { Desc: "设备号", Value: consts.BanType_Device, }, } }