65 lines
1.6 KiB
Go
Raw Permalink Normal View History

2025-04-24 20:39:31 +08:00
package model
import (
2025-04-27 17:23:19 +08:00
"admin/apps/game/model/dto"
2025-04-24 20:39:31 +08:00
"admin/internal/db"
"time"
)
func init() {
db.RegisterTableModels(Ban{})
}
type Ban struct {
2025-04-28 15:56:04 +08:00
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"`
2025-04-24 20:39:31 +08:00
}
func (lm *Ban) TableName() string {
return "ban"
}
func (m *Ban) GetId() int {
return m.ID
}
2025-04-28 15:56:04 +08:00
func (m *Ban) GetServerConfIDChoices(projectId string) []*dto.CommonDtoFieldChoice {
return getChoiceServers(projectId)
}
2025-04-27 17:23:19 +08:00
func (m *Ban) GetBanTypeChoices(projectId string) []*dto.CommonDtoFieldChoice {
return []*dto.CommonDtoFieldChoice{
{
2025-04-28 15:56:04 +08:00
Desc: "账号",
Value: "account",
},
{
Desc: "角色",
Value: "role",
},
{
Desc: "IP",
Value: "ip",
},
{
Desc: "账号发言",
Value: "account_chat",
},
{
Desc: "角色发言",
Value: "role_chat",
2025-04-27 17:23:19 +08:00
},
{
2025-04-28 15:56:04 +08:00
Desc: "设备号",
Value: "device_id",
2025-04-27 17:23:19 +08:00
},
2025-04-24 20:39:31 +08:00
}
}