65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package model
|
||
|
||
import (
|
||
"admin/apps/game/model/dto"
|
||
"admin/internal/db"
|
||
"time"
|
||
)
|
||
|
||
func init() {
|
||
db.RegisterTableModels(Ban{})
|
||
}
|
||
|
||
type Ban struct {
|
||
ID int `gorm:"primarykey" readonly:"true"`
|
||
ProjectId string `gorm:"type:varchar(255);uniqueIndex:idx_ban"`
|
||
ServerConfID string `gorm:"type:varchar(200);uniqueIndex:idx_server" name:"区服id" required:"true" choices:"GetServerConfIDChoices" uneditable:"true"`
|
||
BanType string `name:"封禁类型" required:"true" choices:"GetBanTypeChoices" uneditable:"true"`
|
||
Value string `gorm:"type:varchar(128);uniqueIndex:idx_ban" name:"封禁值" required:"true" desc:"根据封禁类型填对应值,例如ip就填ip地址" uneditable:"true"`
|
||
BanReason string `name:"封禁理由" desc:"封禁理由,会推送给客户端弹窗" required:"true"`
|
||
ExpireAt time.Time `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(projectId string) []*dto.CommonDtoFieldChoice {
|
||
return getChoiceServers(projectId)
|
||
}
|
||
|
||
func (m *Ban) GetBanTypeChoices(projectId string) []*dto.CommonDtoFieldChoice {
|
||
return []*dto.CommonDtoFieldChoice{
|
||
{
|
||
Desc: "账号",
|
||
Value: "account",
|
||
},
|
||
{
|
||
Desc: "角色",
|
||
Value: "role",
|
||
},
|
||
{
|
||
Desc: "IP",
|
||
Value: "ip",
|
||
},
|
||
{
|
||
Desc: "账号发言",
|
||
Value: "account_chat",
|
||
},
|
||
{
|
||
Desc: "角色发言",
|
||
Value: "role_chat",
|
||
},
|
||
{
|
||
Desc: "设备号",
|
||
Value: "device_id",
|
||
},
|
||
}
|
||
}
|