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-30 15:46:14 +08:00
|
|
|
|
"admin/internal/consts"
|
2025-04-24 20:39:31 +08:00
|
|
|
|
"admin/internal/db"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
db.RegisterTableModels(Ban{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Ban struct {
|
2025-04-30 15:46:14 +08:00
|
|
|
|
ID int `gorm:"primarykey" readonly:"true"`
|
|
|
|
|
ProjectId int `gorm:"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"`
|
|
|
|
|
BanNotifyReason string `name:"封禁弹窗" desc:"封禁弹窗内容,会推送给客户端弹窗" required:"true"`
|
|
|
|
|
ExpireAt time.Time `name:"封禁到期时间" desc:"封禁到期时间,0表示永久封禁"`
|
2025-04-28 15:56:04 +08:00
|
|
|
|
|
|
|
|
|
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-30 15:46:14 +08:00
|
|
|
|
func (m *Ban) GetServerConfIDChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
|
|
|
|
return getChoiceServers(project)
|
2025-04-28 15:56:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-30 15:46:14 +08:00
|
|
|
|
func (m *Ban) GetBanTypeChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
|
|
|
|
switch project.ProjectType {
|
|
|
|
|
case consts.RegisteredProjectId_shenmodalu:
|
|
|
|
|
return []*dto.CommonDtoFieldChoice{
|
|
|
|
|
{
|
|
|
|
|
Desc: "角色",
|
|
|
|
|
Value: consts.BanType_Role,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Desc: "角色发言",
|
|
|
|
|
Value: consts.BanType_RoleChat,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-27 17:23:19 +08:00
|
|
|
|
return []*dto.CommonDtoFieldChoice{
|
|
|
|
|
{
|
2025-04-28 15:56:04 +08:00
|
|
|
|
Desc: "账号",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
Value: consts.BanType_Account,
|
2025-04-28 15:56:04 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Desc: "角色",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
Value: consts.BanType_Role,
|
2025-04-28 15:56:04 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Desc: "IP",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
Value: consts.BanType_Ip,
|
2025-04-28 15:56:04 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Desc: "账号发言",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
Value: consts.BanType_AccountChat,
|
2025-04-28 15:56:04 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Desc: "角色发言",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
Value: consts.BanType_RoleChat,
|
2025-04-27 17:23:19 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
2025-04-28 15:56:04 +08:00
|
|
|
|
Desc: "设备号",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
Value: consts.BanType_Device,
|
2025-04-27 17:23:19 +08:00
|
|
|
|
},
|
2025-04-24 20:39:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|