2025-04-24 20:39:31 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
2025-04-30 15:46:14 +08:00
|
|
|
|
"admin/internal/consts"
|
2025-04-24 20:39:31 +08:00
|
|
|
|
"admin/internal/db"
|
2025-05-16 15:17:10 +08:00
|
|
|
|
"admin/internal/model/dto"
|
2025-05-12 18:43:41 +08:00
|
|
|
|
"database/sql"
|
2025-04-24 20:39:31 +08:00
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
db.RegisterTableModels(Ban{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Ban struct {
|
2025-05-12 18:43:41 +08:00
|
|
|
|
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表示永久封禁"`
|
2025-04-28 15:56:04 +08:00
|
|
|
|
|
|
|
|
|
CreatedAt time.Time `readonly:"true"`
|
2025-05-15 17:30:33 +08:00
|
|
|
|
UpdatedAt 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{
|
2025-05-14 18:09:20 +08:00
|
|
|
|
//{
|
|
|
|
|
// Desc: "账号",
|
|
|
|
|
// Value: consts.BanType_Account,
|
|
|
|
|
//},
|
|
|
|
|
//{
|
|
|
|
|
// Desc: "IP",
|
|
|
|
|
// Value: consts.BanType_Ip,
|
|
|
|
|
//},
|
2025-04-30 15:46:14 +08:00
|
|
|
|
{
|
2025-05-14 18:09:20 +08:00
|
|
|
|
Desc: "角色登录",
|
2025-04-30 15:46:14 +08:00
|
|
|
|
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
|
|
|
|
},
|
|
|
|
|
{
|
2025-05-14 18:09:20 +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
|
|
|
|
}
|
|
|
|
|
}
|