126 lines
7.7 KiB
Go
Executable File
126 lines
7.7 KiB
Go
Executable File
// Code generated by goctl. DO NOT EDIT.
|
||
// versions:
|
||
// goctl version: 1.7.6
|
||
|
||
package model
|
||
|
||
import (
|
||
"context"
|
||
"database/sql"
|
||
"fmt"
|
||
"strings"
|
||
|
||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||
"github.com/zeromicro/go-zero/core/stringx"
|
||
)
|
||
|
||
var (
|
||
msGameServerFieldNames = builder.RawFieldNames(&MsGameServer{})
|
||
msGameServerRows = strings.Join(msGameServerFieldNames, ",")
|
||
msGameServerRowsExpectAutoSet = strings.Join(stringx.Remove(msGameServerFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||
msGameServerRowsWithPlaceHolder = strings.Join(stringx.Remove(msGameServerFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||
)
|
||
|
||
type (
|
||
msGameServerModel interface {
|
||
Insert(ctx context.Context, data *MsGameServer) (sql.Result, error)
|
||
FindOne(ctx context.Context, id int) (*MsGameServer, error)
|
||
Update(ctx context.Context, data *MsGameServer) error
|
||
Delete(ctx context.Context, id int) error
|
||
}
|
||
|
||
defaultMsGameServerModel struct {
|
||
conn sqlx.SqlConn
|
||
table string
|
||
}
|
||
|
||
MsGameServer struct {
|
||
Id int `db:"id"` // ID
|
||
AgentId int `db:"agent_id"` // 代理ID
|
||
ServerId int `db:"server_id"` // 服务器ID
|
||
AgentServer sql.NullInt64 `db:"agent_server"` // agent_id 和 server_id的组合(agent_id*10000000 + server_id)
|
||
ServerName string `db:"server_name"` // 服名称
|
||
ServerServerId sql.NullInt64 `db:"server_server_id"` // 游戏节点服的物理服务器ID
|
||
MainNodes sql.NullString `db:"main_nodes"` // 主节点集合
|
||
Gateways sql.NullString `db:"gateways"` // 网关节点集合
|
||
GatewayPort int `db:"gateway_port"` // 游戏服端口
|
||
GameCode string `db:"game_code"` // 游戏名
|
||
AgentCode string `db:"agent_code"` // 代理
|
||
Branch string `db:"branch"` // 分支
|
||
ServerStartTime sql.NullTime `db:"server_start_time"` // 开服时间
|
||
WebPort int `db:"web_port"` // web访问端口
|
||
LogLevel int `db:"log_level"` // 日志等级
|
||
LogDir string `db:"log_dir"` // 日志地址
|
||
IsDebug string `db:"is_debug"` // debug是否开启,默认false
|
||
BackgroundLogOpen string `db:"background_log_open"` // 是否记录后台日志,默认开启
|
||
CenterId int `db:"center_id"` // 游戏中央服id
|
||
CenterIp string `db:"center_ip"` // 游戏中央服ip
|
||
ReplayId int `db:"replay_id"` // 重播日志服务器id
|
||
CrossId int `db:"cross_id"` // 跨服服务器id
|
||
DbServerId sql.NullInt64 `db:"db_server_id"` // 游戏业务数据库的物理服务器ID
|
||
DbPort int `db:"db_port"` // 游戏数据库port
|
||
RedisServerId sql.NullInt64 `db:"redis_server_id"` // redis的物理服务器ID
|
||
RedisPort sql.NullInt64 `db:"redis_port"` // redis端口
|
||
AdminServerId sql.NullInt64 `db:"admin_server_id"` // 游戏日志数据库的物理服务器ID
|
||
AdminPort int `db:"admin_port"` // 日志数据库端口
|
||
SdkVerifyUrl string `db:"sdk_verify_url"` // SDK验证地址
|
||
SdkVerifySandboxUrl string `db:"sdk_verify_sandbox_url"` // SDK验证地址(沙盒)
|
||
WebUrl string `db:"web_url"` // API接口域名
|
||
EsUrl string `db:"es_url"` // ES接口地址
|
||
IsMerge uint `db:"is_merge"` // 是否是合服后的新服
|
||
MergeTime sql.NullString `db:"merge_time"` // 合服时间
|
||
HbCheckClosed string `db:"hb_check_closed"` // 心跳包检查是否关闭,默认关闭
|
||
ItemBanList sql.NullString `db:"item_ban_list"` // 禁用道具
|
||
RegionIso string `db:"region_iso"` // 地区ISO
|
||
BytedanceLogOpen string `db:"bytedance_log_open"` // 字节跳动元宝日志,默认开启
|
||
IsFightLog string `db:"is_fight_log"` // 是否开启战斗日志,默认false
|
||
CookieExtend string `db:"cookie_extend"` // 节点cookie
|
||
IsOverseas int8 `db:"is_overseas"` // 0:国内 1:国外
|
||
Status int8 `db:"status"` // 1:正常; 2:被合服了; 4:关服
|
||
}
|
||
)
|
||
|
||
func newMsGameServerModel(conn sqlx.SqlConn) *defaultMsGameServerModel {
|
||
return &defaultMsGameServerModel{
|
||
conn: conn,
|
||
table: "`ms_game_server`",
|
||
}
|
||
}
|
||
|
||
func (m *defaultMsGameServerModel) Delete(ctx context.Context, id int) error {
|
||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||
return err
|
||
}
|
||
|
||
func (m *defaultMsGameServerModel) FindOne(ctx context.Context, id int) (*MsGameServer, error) {
|
||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", msGameServerRows, m.table)
|
||
var resp MsGameServer
|
||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||
switch err {
|
||
case nil:
|
||
return &resp, nil
|
||
case sqlx.ErrNotFound:
|
||
return nil, ErrNotFound
|
||
default:
|
||
return nil, err
|
||
}
|
||
}
|
||
|
||
func (m *defaultMsGameServerModel) Insert(ctx context.Context, data *MsGameServer) (sql.Result, error) {
|
||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, msGameServerRowsExpectAutoSet)
|
||
ret, err := m.conn.ExecCtx(ctx, query, data.AgentId, data.ServerId, data.AgentServer, data.ServerName, data.ServerServerId, data.MainNodes, data.Gateways, data.GatewayPort, data.GameCode, data.AgentCode, data.Branch, data.ServerStartTime, data.WebPort, data.LogLevel, data.LogDir, data.IsDebug, data.BackgroundLogOpen, data.CenterId, data.CenterIp, data.ReplayId, data.CrossId, data.DbServerId, data.DbPort, data.RedisServerId, data.RedisPort, data.AdminServerId, data.AdminPort, data.SdkVerifyUrl, data.SdkVerifySandboxUrl, data.WebUrl, data.EsUrl, data.IsMerge, data.MergeTime, data.HbCheckClosed, data.ItemBanList, data.RegionIso, data.BytedanceLogOpen, data.IsFightLog, data.CookieExtend, data.IsOverseas, data.Status)
|
||
return ret, err
|
||
}
|
||
|
||
func (m *defaultMsGameServerModel) Update(ctx context.Context, data *MsGameServer) error {
|
||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, msGameServerRowsWithPlaceHolder)
|
||
_, err := m.conn.ExecCtx(ctx, query, data.AgentId, data.ServerId, data.AgentServer, data.ServerName, data.ServerServerId, data.MainNodes, data.Gateways, data.GatewayPort, data.GameCode, data.AgentCode, data.Branch, data.ServerStartTime, data.WebPort, data.LogLevel, data.LogDir, data.IsDebug, data.BackgroundLogOpen, data.CenterId, data.CenterIp, data.ReplayId, data.CrossId, data.DbServerId, data.DbPort, data.RedisServerId, data.RedisPort, data.AdminServerId, data.AdminPort, data.SdkVerifyUrl, data.SdkVerifySandboxUrl, data.WebUrl, data.EsUrl, data.IsMerge, data.MergeTime, data.HbCheckClosed, data.ItemBanList, data.RegionIso, data.BytedanceLogOpen, data.IsFightLog, data.CookieExtend, data.IsOverseas, data.Status, data.Id)
|
||
return err
|
||
}
|
||
|
||
func (m *defaultMsGameServerModel) tableName() string {
|
||
return m.table
|
||
}
|