From 63667de00e6674620734a0506e4362df69825ba8 Mon Sep 17 00:00:00 2001 From: linquan <349589071@qq.com> Date: Tue, 15 Apr 2025 18:08:16 +0800 Subject: [PATCH] server Json,OperLog --- api/v1/game/ccd.go | 23 ++ api/v1/game/pub.go | 23 ++ internal/controller/game_login_url.go | 5 + internal/controller/game_pub.go | 5 + internal/dao/game_router.go | 27 +++ internal/dao/game_server_json.go | 27 +++ internal/dao/game_server_json_general.go | 27 +++ internal/dao/internal/game_login_url.go | 14 ++ internal/dao/internal/game_router.go | 91 +++++++ internal/dao/internal/game_server_json.go | 83 +++++++ .../dao/internal/game_server_json_general.go | 85 +++++++ internal/model/do/game_login_url.go | 8 + internal/model/do/game_router.go | 24 ++ internal/model/do/game_server_json.go | 21 ++ internal/model/do/game_server_json_general.go | 21 ++ internal/model/entity/game_login_url.go | 35 ++- internal/model/entity/game_router.go | 19 ++ internal/model/entity/game_server_json.go | 19 ++ .../model/entity/game_server_json_general.go | 16 ++ internal/service/middleware.go | 16 +- internal/serviceGame/loginUrl.go | 29 ++- internal/serviceGame/manage.go | 228 +++++++++++------- internal/serviceGame/pub.go | 44 ++++ utils/util.go | 7 +- 24 files changed, 796 insertions(+), 101 deletions(-) create mode 100644 internal/dao/game_router.go create mode 100644 internal/dao/game_server_json.go create mode 100644 internal/dao/game_server_json_general.go create mode 100644 internal/dao/internal/game_router.go create mode 100644 internal/dao/internal/game_server_json.go create mode 100644 internal/dao/internal/game_server_json_general.go create mode 100644 internal/model/do/game_router.go create mode 100644 internal/model/do/game_server_json.go create mode 100644 internal/model/do/game_server_json_general.go create mode 100644 internal/model/entity/game_router.go create mode 100644 internal/model/entity/game_server_json.go create mode 100644 internal/model/entity/game_server_json_general.go diff --git a/api/v1/game/ccd.go b/api/v1/game/ccd.go index e79fcb0..d5b7afc 100644 --- a/api/v1/game/ccd.go +++ b/api/v1/game/ccd.go @@ -57,6 +57,15 @@ type GetLoginUrlRes struct { Total int `json:"total"` } +type GetServerConfigGeneralReq struct { + g.Meta `path:"/ServerConfig/getGeneral" tags:"登录地址" method:"post" summary:"ServerConfig"` +} + +type GetServerConfigGeneralRes struct { + g.Meta `mime:"application/json"` + List []entity.GameServerJsonGeneral `json:"list"` +} + type GetAllLoginUrlReq struct { g.Meta `path:"/loginUrl/getAllLoginUrl" tags:"登录地址" method:"post" summary:"allLoginUrl"` } @@ -78,6 +87,20 @@ type AddLoginUrlReq struct { type AddLoginUrlRes struct { } +type AddServerConfigGeneralReq struct { + g.Meta `path:"/ServerConfig/addGeneral" tags:"登录地址" method:"post" summary:"添加loginUrl"` + Id int `p:"id"` + BackstageRechargeUrl string `p:"backstageRechargeUrl"` + GmWhiteListUrl string `p:"gmWhiteListUrl"` + IdentityCheckAddress string `p:"identityCheckAddress"` + RechargeWhiteListIps string `p:"rechargeWhiteListIps"` + SdkAddress string `p:"sdkAddress"` + UniqueAddress string `p:"uniqueAddress"` +} + +type AddServerConfigGeneralRes struct { +} + type DelLoginUrlReq struct { g.Meta `path:"/loginUrl/delLoginUrl" tags:"登录地址" method:"post" summary:"删除loginUrl"` Id uint64 `p:"id"` diff --git a/api/v1/game/pub.go b/api/v1/game/pub.go index f6f9c20..05cb0ed 100644 --- a/api/v1/game/pub.go +++ b/api/v1/game/pub.go @@ -39,6 +39,7 @@ type LoginUrlData struct { Last int `json:"last" description:"上次登录标识,1-登录"` Scale int `json:"scale" description:"玩家规模等级"` AccountName string `json:"accountName" description:"玩家名称"` + CreateTime int64 `json:"createTime" description:"创建时间"` } type GetGameLoginUrlRes struct { @@ -225,3 +226,25 @@ type GetOpenIdRes struct { g.Meta `mime:"application/json"` State int `json:"state"` } + +type GetServerConfigReq struct { + g.Meta `path:"/getServerConfig" tags:"外部接口" method:"get" summary:"获取服务器配置"` + ServerId int `p:"serverId"` +} + +type GetServerConfigRes struct { + g.Meta `mime:"application/json"` + Id int `json:"serverId" description:""` + SdkAddress string `json:"sdkAddress" description:""` + UniqueAddress string `json:"uniqueAddress" description:""` + IdentityCheckAddress string `json:"identityCheckAddress" description:""` + RechargeWhiteListIps string `json:"rechargeWhiteListIps" description:""` + GmWhiteListUrl string `json:"gmWhiteListUrl" description:""` + BackstageRechargeUrl string `json:"backstageRechargeUrl" description:""` + GameDifficulty int `json:"gameDifficulty" description:""` + GameDbUrl string `json:"gameDbUrl" description:""` + GameDbName string `json:"gameDbName" description:""` + Platform int `json:"platform" description:""` + InnerIp string `json:"innerIp" description:""` + CreateTime int64 `json:"createTime" description:""` +} diff --git a/internal/controller/game_login_url.go b/internal/controller/game_login_url.go index 68350b7..76728d8 100644 --- a/internal/controller/game_login_url.go +++ b/internal/controller/game_login_url.go @@ -17,6 +17,11 @@ func (c *loginUrlController) Get(ctx context.Context, req *game.GetLoginUrlReq) return } +func (c *loginUrlController) GetServerConfigGeneral(ctx context.Context, req *game.GetServerConfigGeneralReq) (res *game.GetServerConfigGeneralRes, err error) { + res, err = serviceGame.GameLoginUrl().GetServerConfigGeneral(ctx, req) + return +} + func (c *loginUrlController) GetAll(ctx context.Context, req *game.GetAllLoginUrlReq) (res *game.GetAllLoginUrlRes, err error) { res, err = serviceGame.GameLoginUrl().GetAllLoginUrl(ctx, req) return diff --git a/internal/controller/game_pub.go b/internal/controller/game_pub.go index 4c4f5cd..2f56873 100644 --- a/internal/controller/game_pub.go +++ b/internal/controller/game_pub.go @@ -209,3 +209,8 @@ func (c *pubController) SetGmToClient(ctx context.Context, req *game.SetGmToClie res, err = serviceGame.GameManage().SetGmToClient(ctx, req) return } + +func (c *pubController) GetServerConfig(ctx context.Context, req *game.GetServerConfigReq) (res *game.GetServerConfigRes, err error) { + res, err = serviceGame.GamePub().GetServerConfig(ctx, req) + return +} diff --git a/internal/dao/game_router.go b/internal/dao/game_router.go new file mode 100644 index 0000000..da82df3 --- /dev/null +++ b/internal/dao/game_router.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "tyj_admin/internal/dao/internal" +) + +// internalGameRouterDao is internal type for wrapping internal DAO implements. +type internalGameRouterDao = *internal.GameRouterDao + +// gameRouterDao is the data access object for table game_router. +// You can define custom methods on it to extend its functionality as you wish. +type gameRouterDao struct { + internalGameRouterDao +} + +var ( + // GameRouter is globally public accessible object for table game_router operations. + GameRouter = gameRouterDao{ + internal.NewGameRouterDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/game_server_json.go b/internal/dao/game_server_json.go new file mode 100644 index 0000000..fd5e2cf --- /dev/null +++ b/internal/dao/game_server_json.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "tyj_admin/internal/dao/internal" +) + +// internalGameServerJsonDao is internal type for wrapping internal DAO implements. +type internalGameServerJsonDao = *internal.GameServerJsonDao + +// gameServerJsonDao is the data access object for table game_server_json. +// You can define custom methods on it to extend its functionality as you wish. +type gameServerJsonDao struct { + internalGameServerJsonDao +} + +var ( + // GameServerJson is globally public accessible object for table game_server_json operations. + GameServerJson = gameServerJsonDao{ + internal.NewGameServerJsonDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/game_server_json_general.go b/internal/dao/game_server_json_general.go new file mode 100644 index 0000000..2b9d523 --- /dev/null +++ b/internal/dao/game_server_json_general.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package dao + +import ( + "tyj_admin/internal/dao/internal" +) + +// internalGameServerJsonGeneralDao is internal type for wrapping internal DAO implements. +type internalGameServerJsonGeneralDao = *internal.GameServerJsonGeneralDao + +// gameServerJsonGeneralDao is the data access object for table game_server_json_general. +// You can define custom methods on it to extend its functionality as you wish. +type gameServerJsonGeneralDao struct { + internalGameServerJsonGeneralDao +} + +var ( + // GameServerJsonGeneral is globally public accessible object for table game_server_json_general operations. + GameServerJsonGeneral = gameServerJsonGeneralDao{ + internal.NewGameServerJsonGeneralDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/internal/game_login_url.go b/internal/dao/internal/game_login_url.go index de32591..54b141e 100644 --- a/internal/dao/internal/game_login_url.go +++ b/internal/dao/internal/game_login_url.go @@ -32,6 +32,13 @@ type GameLoginUrlColumns struct { Area string // 区服 IsShow string // 1-可见,0-不可见 Channel string // 固定渠道 + CDate string // 创建时间-用于排序 + GameDbUrl string // 数据库地址 + GameDbName string // 数据库名称 + Platform string // 平台-充值 + InnerIp string // 内外地址 + CreateTime string // 开服时间-用于服务器时间 + Remark string // 备注名称 } // gameLoginUrlColumns holds the columns for table game_login_url. @@ -48,6 +55,13 @@ var gameLoginUrlColumns = GameLoginUrlColumns{ Area: "area", IsShow: "isShow", Channel: "channel", + CDate: "c_date", + GameDbUrl: "game_db_url", + GameDbName: "game_db_name", + Platform: "platform", + InnerIp: "inner_ip", + CreateTime: "create_time", + Remark: "remark", } // NewGameLoginUrlDao creates and returns a new DAO object for table data access. diff --git a/internal/dao/internal/game_router.go b/internal/dao/internal/game_router.go new file mode 100644 index 0000000..de19704 --- /dev/null +++ b/internal/dao/internal/game_router.go @@ -0,0 +1,91 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// GameRouterDao is the data access object for table game_router. +type GameRouterDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns GameRouterColumns // columns contains all the column names of Table for convenient usage. +} + +// GameRouterColumns defines and stores column names for table game_router. +type GameRouterColumns struct { + Id string // + ServerId string // + RealmIp string // + RealmPort string // + RealmStep string // + RealmNum string // + RouterIp string // + RouterPort string // + RouterNum string // + RouterStep string // +} + +// gameRouterColumns holds the columns for table game_router. +var gameRouterColumns = GameRouterColumns{ + Id: "id", + ServerId: "server_id", + RealmIp: "realm_ip", + RealmPort: "realm_port", + RealmStep: "realm_step", + RealmNum: "realm_num", + RouterIp: "router_ip", + RouterPort: "router_port", + RouterNum: "router_num", + RouterStep: "router_step", +} + +// NewGameRouterDao creates and returns a new DAO object for table data access. +func NewGameRouterDao() *GameRouterDao { + return &GameRouterDao{ + group: "default", + table: "game_router", + columns: gameRouterColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *GameRouterDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *GameRouterDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *GameRouterDao) Columns() GameRouterColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *GameRouterDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *GameRouterDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *GameRouterDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/internal/game_server_json.go b/internal/dao/internal/game_server_json.go new file mode 100644 index 0000000..1debccd --- /dev/null +++ b/internal/dao/internal/game_server_json.go @@ -0,0 +1,83 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// GameServerJsonDao is the data access object for table game_server_json. +type GameServerJsonDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns GameServerJsonColumns // columns contains all the column names of Table for convenient usage. +} + +// GameServerJsonColumns defines and stores column names for table game_server_json. +type GameServerJsonColumns struct { + Id string // + GameDbUrl string // + GameDbName string // + Platform string // + InnerIp string // + CreateTime string // +} + +// gameServerJsonColumns holds the columns for table game_server_json. +var gameServerJsonColumns = GameServerJsonColumns{ + Id: "id", + GameDbUrl: "game_db_url", + GameDbName: "game_db_name", + Platform: "platform", + InnerIp: "inner_ip", + CreateTime: "create_time", +} + +// NewGameServerJsonDao creates and returns a new DAO object for table data access. +func NewGameServerJsonDao() *GameServerJsonDao { + return &GameServerJsonDao{ + group: "default", + table: "game_server_json", + columns: gameServerJsonColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *GameServerJsonDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *GameServerJsonDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *GameServerJsonDao) Columns() GameServerJsonColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *GameServerJsonDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *GameServerJsonDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *GameServerJsonDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/internal/game_server_json_general.go b/internal/dao/internal/game_server_json_general.go new file mode 100644 index 0000000..b567446 --- /dev/null +++ b/internal/dao/internal/game_server_json_general.go @@ -0,0 +1,85 @@ +// ========================================================================== +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// GameServerJsonGeneralDao is the data access object for table game_server_json_general. +type GameServerJsonGeneralDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of current DAO. + columns GameServerJsonGeneralColumns // columns contains all the column names of Table for convenient usage. +} + +// GameServerJsonGeneralColumns defines and stores column names for table game_server_json_general. +type GameServerJsonGeneralColumns struct { + Id string // + SdkAddress string // + UniqueAddress string // + IdentityCheckAddress string // + RechargeWhiteListIps string // + GmWhiteListUrl string // + BackstageRechargeUrl string // +} + +// gameServerJsonGeneralColumns holds the columns for table game_server_json_general. +var gameServerJsonGeneralColumns = GameServerJsonGeneralColumns{ + Id: "id", + SdkAddress: "sdk_address", + UniqueAddress: "unique_address", + IdentityCheckAddress: "identity_check_address", + RechargeWhiteListIps: "recharge_white_list_ips", + GmWhiteListUrl: "gm_white_list_url", + BackstageRechargeUrl: "backstage_recharge_url", +} + +// NewGameServerJsonGeneralDao creates and returns a new DAO object for table data access. +func NewGameServerJsonGeneralDao() *GameServerJsonGeneralDao { + return &GameServerJsonGeneralDao{ + group: "default", + table: "game_server_json_general", + columns: gameServerJsonGeneralColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *GameServerJsonGeneralDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *GameServerJsonGeneralDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *GameServerJsonGeneralDao) Columns() GameServerJsonGeneralColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *GameServerJsonGeneralDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *GameServerJsonGeneralDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function f +// as it is automatically handled by this function. +func (dao *GameServerJsonGeneralDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/model/do/game_login_url.go b/internal/model/do/game_login_url.go index cf6fd86..6494c3d 100644 --- a/internal/model/do/game_login_url.go +++ b/internal/model/do/game_login_url.go @@ -6,6 +6,7 @@ package do import ( "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" ) // GameLoginUrl is the golang structure of table game_login_url for DAO operations like Where/Data. @@ -23,4 +24,11 @@ type GameLoginUrl struct { Area interface{} // 区服 IsShow interface{} // 1-可见,0-不可见 Channel interface{} // 固定渠道 + CDate *gtime.Time // 创建时间-用于排序 + GameDbUrl interface{} // 数据库地址 + GameDbName interface{} // 数据库名称 + Platform interface{} // 平台-充值 + InnerIp interface{} // 内外地址 + CreateTime *gtime.Time // 开服时间-用于服务器时间 + Remark interface{} // 备注名称 } diff --git a/internal/model/do/game_router.go b/internal/model/do/game_router.go new file mode 100644 index 0000000..bbe916f --- /dev/null +++ b/internal/model/do/game_router.go @@ -0,0 +1,24 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// GameRouter is the golang structure of table game_router for DAO operations like Where/Data. +type GameRouter struct { + g.Meta `orm:"table:game_router, do:true"` + Id interface{} // + ServerId interface{} // + RealmIp interface{} // + RealmPort interface{} // + RealmStep interface{} // + RealmNum interface{} // + RouterIp interface{} // + RouterPort interface{} // + RouterNum interface{} // + RouterStep interface{} // +} diff --git a/internal/model/do/game_server_json.go b/internal/model/do/game_server_json.go new file mode 100644 index 0000000..c7bcf78 --- /dev/null +++ b/internal/model/do/game_server_json.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" +) + +// GameServerJson is the golang structure of table game_server_json for DAO operations like Where/Data. +type GameServerJson struct { + g.Meta `orm:"table:game_server_json, do:true"` + Id interface{} // + GameDbUrl interface{} // + GameDbName interface{} // + Platform interface{} // + InnerIp interface{} // + CreateTime *gtime.Time // +} diff --git a/internal/model/do/game_server_json_general.go b/internal/model/do/game_server_json_general.go new file mode 100644 index 0000000..fcd301d --- /dev/null +++ b/internal/model/do/game_server_json_general.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// GameServerJsonGeneral is the golang structure of table game_server_json_general for DAO operations like Where/Data. +type GameServerJsonGeneral struct { + g.Meta `orm:"table:game_server_json_general, do:true"` + Id interface{} // + SdkAddress interface{} // + UniqueAddress interface{} // + IdentityCheckAddress interface{} // + RechargeWhiteListIps interface{} // + GmWhiteListUrl interface{} // + BackstageRechargeUrl interface{} // +} diff --git a/internal/model/entity/game_login_url.go b/internal/model/entity/game_login_url.go index ab70f24..2cc8ec0 100644 --- a/internal/model/entity/game_login_url.go +++ b/internal/model/entity/game_login_url.go @@ -4,18 +4,29 @@ package entity +import ( + "github.com/gogf/gf/v2/os/gtime" +) + // GameLoginUrl is the golang structure for table game_login_url. type GameLoginUrl struct { - Id int `json:"id" description:"100+为外网id"` - Host string `json:"host" description:""` - Port int `json:"port" description:""` - State int `json:"state" description:"服务器状态,1-正常,2-维护,3-白名单ip优先加渠道,4-黑名单渠道优先"` - Recommend int `json:"recommend" description:"推荐,1-推荐,0-不推荐"` - Name string `json:"name" description:"名称"` - Difficulty int `json:"difficulty" description:"难度,1-简单,2-困难"` - RechargeHost string `json:"rechargeHost" description:""` - RechargePort int `json:"rechargePort" description:""` - Area int `json:"area" description:"区服"` - IsShow int `json:"isShow" description:"1-可见,0-不可见"` - Channel string `json:"channel" description:"固定渠道"` + Id int `json:"id" description:"100+为外网id"` + Host string `json:"host" description:""` + Port int `json:"port" description:""` + State int `json:"state" description:"服务器状态,1-正常,2-维护,3-白名单ip优先加渠道,4-黑名单渠道优先"` + Recommend int `json:"recommend" description:"推荐,1-推荐,0-不推荐"` + Name string `json:"name" description:"名称"` + Difficulty int `json:"difficulty" description:"难度,1-简单,2-困难"` + RechargeHost string `json:"rechargeHost" description:""` + RechargePort int `json:"rechargePort" description:""` + Area int `json:"area" description:"区服"` + IsShow int `json:"isShow" description:"1-可见,0-不可见"` + Channel string `json:"channel" description:"固定渠道"` + CDate *gtime.Time `json:"cDate" description:"创建时间-用于排序"` + GameDbUrl string `json:"gameDbUrl" description:"数据库地址"` + GameDbName string `json:"gameDbName" description:"数据库名称"` + Platform int `json:"platform" description:"平台-充值"` + InnerIp string `json:"innerIp" description:"内外地址"` + CreateTime *gtime.Time `json:"createTime" description:"开服时间-用于服务器时间"` + Remark string `json:"remark" description:"备注名称"` } diff --git a/internal/model/entity/game_router.go b/internal/model/entity/game_router.go new file mode 100644 index 0000000..20f283d --- /dev/null +++ b/internal/model/entity/game_router.go @@ -0,0 +1,19 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// GameRouter is the golang structure for table game_router. +type GameRouter struct { + Id int `json:"id" description:""` + ServerId string `json:"serverId" description:""` + RealmIp string `json:"realmIp" description:""` + RealmPort int `json:"realmPort" description:""` + RealmStep int `json:"realmStep" description:""` + RealmNum int `json:"realmNum" description:""` + RouterIp string `json:"routerIp" description:""` + RouterPort int `json:"routerPort" description:""` + RouterNum int `json:"routerNum" description:""` + RouterStep int `json:"routerStep" description:""` +} diff --git a/internal/model/entity/game_server_json.go b/internal/model/entity/game_server_json.go new file mode 100644 index 0000000..010527d --- /dev/null +++ b/internal/model/entity/game_server_json.go @@ -0,0 +1,19 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// GameServerJson is the golang structure for table game_server_json. +type GameServerJson struct { + Id int `json:"id" description:""` + GameDbUrl string `json:"gameDbUrl" description:""` + GameDbName string `json:"gameDbName" description:""` + Platform int `json:"platform" description:""` + InnerIp string `json:"innerIp" description:""` + CreateTime *gtime.Time `json:"createTime" description:""` +} diff --git a/internal/model/entity/game_server_json_general.go b/internal/model/entity/game_server_json_general.go new file mode 100644 index 0000000..55bf105 --- /dev/null +++ b/internal/model/entity/game_server_json_general.go @@ -0,0 +1,16 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// GameServerJsonGeneral is the golang structure for table game_server_json_general. +type GameServerJsonGeneral struct { + Id int `json:"id" description:""` + SdkAddress string `json:"sdkAddress" description:""` + UniqueAddress string `json:"uniqueAddress" description:""` + IdentityCheckAddress string `json:"identityCheckAddress" description:""` + RechargeWhiteListIps string `json:"rechargeWhiteListIps" description:""` + GmWhiteListUrl string `json:"gmWhiteListUrl" description:""` + BackstageRechargeUrl string `json:"backstageRechargeUrl" description:""` +} diff --git a/internal/service/middleware.go b/internal/service/middleware.go index 1b6ae56..ef62e84 100644 --- a/internal/service/middleware.go +++ b/internal/service/middleware.go @@ -15,6 +15,7 @@ import ( "github.com/gogf/gf/v2/util/gconv" "log" "time" + "tyj_admin/internal/consts" "tyj_admin/internal/dao" "tyj_admin/internal/model" "tyj_admin/library/libResponse" @@ -144,6 +145,13 @@ func (s *middlewareImpl) Auth(r *ghttp.Request) { // 操作日志 处理中间件 func (s *middlewareImpl) OperLog(r *ghttp.Request) { + r.Middleware.Next() + + // There's custom buffer content, it then exits current handler. + if r.Response.BufferLength() > 0 { + return + } + ctx := r.GetCtx() //获取登陆用户id user := Context().GetLoginUser(ctx) @@ -153,9 +161,9 @@ func (s *middlewareImpl) OperLog(r *ghttp.Request) { } dao.SysOperLog.Ctx(ctx).Insert(g.Map{ - dao.SysOperLog.Columns().Title: "", + dao.SysOperLog.Columns().Title: "game.v1", dao.SysOperLog.Columns().BusinessType: 0, - dao.SysOperLog.Columns().Method: r.URL, + dao.SysOperLog.Columns().Method: r.Method, dao.SysOperLog.Columns().RequestMethod: r.Method, dao.SysOperLog.Columns().OperatorType: 0, dao.SysOperLog.Columns().OperName: userName, @@ -163,8 +171,8 @@ func (s *middlewareImpl) OperLog(r *ghttp.Request) { dao.SysOperLog.Columns().OperIp: r.GetClientIp(), dao.SysOperLog.Columns().OperLocation: r.RemoteAddr, dao.SysOperLog.Columns().OperParam: r.URL.RawQuery, - dao.SysOperLog.Columns().OperTime: time.Now(), + dao.SysOperLog.Columns().JsonResult: r.GetHandlerResponse(), + dao.SysOperLog.Columns().OperTime: time.Now().Local().Format(consts.TIME_FORMAT), }) - r.Middleware.Next() } diff --git a/internal/serviceGame/loginUrl.go b/internal/serviceGame/loginUrl.go index ba3c2fb..a090a03 100644 --- a/internal/serviceGame/loginUrl.go +++ b/internal/serviceGame/loginUrl.go @@ -19,6 +19,8 @@ import ( type IGameLoginUrl interface { GetLoginUrl(ctx context.Context, req *game.GetLoginUrlReq) (res *game.GetLoginUrlRes, err error) + GetServerConfigGeneral(ctx context.Context, req *game.GetServerConfigGeneralReq) (res *game.GetServerConfigGeneralRes, err error) + AddServerConfigGeneral(ctx context.Context, req *game.AddServerConfigGeneralReq) (res *game.AddServerConfigGeneralRes, err error) GetAllLoginUrl(ctx context.Context, req *game.GetAllLoginUrlReq) (res *game.GetAllLoginUrlRes, err error) AddLoginUrl(ctx context.Context, req *game.AddLoginUrlReq) (res *game.AddLoginUrlRes, err error) DelLoginUrl(ctx context.Context, req *game.DelLoginUrlReq) (res *game.DelLoginUrlRes, err error) @@ -47,6 +49,31 @@ func (c *gameLoginUrlImpl) GetLoginUrl(ctx context.Context, req *game.GetLoginUr }) return } +func (c *gameLoginUrlImpl) GetServerConfigGeneral(ctx context.Context, req *game.GetServerConfigGeneralReq) (res *game.GetServerConfigGeneralRes, err error) { + g.Try(ctx, func(ctx context.Context) { + res = new(game.GetServerConfigGeneralRes) + err = dao.GameServerJsonGeneral.Ctx(ctx).Scan(&res.List) + liberr.ErrIsNil(ctx, err, "mysql err") + }) + return +} + +func (c *gameLoginUrlImpl) AddServerConfigGeneral(ctx context.Context, req *game.AddServerConfigGeneralReq) (res *game.AddServerConfigGeneralRes, err error) { + g.Try(ctx, func(ctx context.Context) { + res = new(game.AddServerConfigGeneralRes) + _, err = dao.GameServerJsonGeneral.Ctx(ctx).Where("id=?", req.Id).Update(g.Map{ + dao.GameServerJsonGeneral.Columns().BackstageRechargeUrl: req.BackstageRechargeUrl, + dao.GameServerJsonGeneral.Columns().IdentityCheckAddress: req.IdentityCheckAddress, + dao.GameServerJsonGeneral.Columns().UniqueAddress: req.UniqueAddress, + dao.GameServerJsonGeneral.Columns().RechargeWhiteListIps: req.RechargeWhiteListIps, + dao.GameServerJsonGeneral.Columns().GmWhiteListUrl: req.GmWhiteListUrl, + dao.GameServerJsonGeneral.Columns().SdkAddress: req.SdkAddress, + }) + liberr.ErrIsNil(ctx, err, "mysql err") + }) + return +} + func (c *gameLoginUrlImpl) GetAllLoginUrl(ctx context.Context, req *game.GetAllLoginUrlReq) (res *game.GetAllLoginUrlRes, err error) { g.Try(ctx, func(ctx context.Context) { res = new(game.GetAllLoginUrlRes) @@ -139,7 +166,7 @@ func (c *gameLoginUrlImpl) GetGameLoginUrl(ctx context.Context, req *game.GetGam } var data = game.LoginUrlData{Id: v.Id, Host: v.Host, Port: v.Port, Difficulty: v.Difficulty, - Recommend: v.Recommend, Name: v.Name, State: v.State, Area: v.Area} + Recommend: v.Recommend, Name: v.Name, State: v.State, Area: v.Area, CreateTime: v.CDate.Unix()} if data.State == consts.Login_URL_STATE_WHITE { if utils.ContainsWhiteList(list, ip) || utils.ContainsWhiteList(list, req.Channel) { data.State = consts.Login_URL_STATE_NORMAL diff --git a/internal/serviceGame/manage.go b/internal/serviceGame/manage.go index 55f624d..5736e5c 100644 --- a/internal/serviceGame/manage.go +++ b/internal/serviceGame/manage.go @@ -1,7 +1,6 @@ package serviceGame import ( - "bytes" "context" "encoding/json" "errors" @@ -12,8 +11,6 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "log" "os" - "os/exec" - "runtime" "strings" "time" "tyj_admin/api/v1/game" @@ -624,52 +621,84 @@ func (ga *gameManageImpl) CopyUnit(ctx context.Context, req *game.CopyUnitReq) ( storeFilename := "storeComponent" + fmt.Sprint(req.SrcName) + ".json" userDir := "./download/" + filename storeDir := "./download/" + storeFilename - cmdName := "getData" + fmt.Sprint(time.Now().Unix()) + //cmdName := "getData" + fmt.Sprint(time.Now().Unix()) + g.Try(ctx, func(ctx context.Context) { - if runtime.GOOS == "linux" { - // LINUX系统 - wireteString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=Unit --out=\"%s\" --query=\"{\\\"UniqueId\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", - mongoConfig.Link1, mongoConfig.Auth, userDir, req.SrcName) - writeString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=StoreComponent --out=\"%s\" --query=\"{\\\"_id\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", - mongoConfig.Link1, mongoConfig.Auth, storeDir, unit.Uid) - log.Println(wireteString) - log.Println(writeString) - if err = os.WriteFile("./"+cmdName+".sh", []byte(wireteString+"\n"+writeString), 0666); err != nil { - log.Fatal(err) - return - } - cmd := exec.Command("sh", cmdName+".sh") - var stdout, stderr bytes.Buffer - cmd.Stdout = &stdout // 标准输出 - cmd.Stderr = &stderr // 标准错误 - err = cmd.Run() - if err != nil { - log.Fatalf("cmd.Run() failed with %s\n", err) - return - } - outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) - fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) + name := "mongoexport" + args := []string{} + args1 := []string{} + + args = append(args, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1)) + args = append(args, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth)) + args1 = append(args1, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1)) + args1 = append(args1, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth)) + args = append(args, "--collection=Unit") + args = append(args, "--jsonArray") + args = append(args, fmt.Sprintf("--out=\"%s\"", userDir)) + args = append(args, fmt.Sprintf("--query=\"{\\\"UniqueId\\\":%d}\"", req.SrcName)) + args = append(args, "--jsonFormat=canonical") + args = append(args, "--type=json") + args1 = append(args1, "--collection=StoreComponent") + args1 = append(args1, "--jsonArray") + args1 = append(args1, fmt.Sprintf("--out=\"%s\"", storeDir)) + args1 = append(args1, fmt.Sprintf("--query=\"{\\\"_id\\\":%d}\"", unit.Uid)) + args1 = append(args1, "--jsonFormat=canonical") + args1 = append(args1, "--type=json") + + err = utils.CmdCommand(ctx, name, args...) + if err != nil { + log.Printf("cmd.Run() args failed with %s\n", err) + return } - - if runtime.GOOS == "windows" { - // windows系统 - writeString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=Unit --out=\"%s\" --query=\"{\\\"UniqueId\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", - mongoConfig.Link1, mongoConfig.Auth, userDir, req.SrcName) - storeWriteString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=StoreComponent --out=\"%s\" --query=\"{\\\"_id\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", - mongoConfig.Link1, mongoConfig.Auth, storeDir, unit.Uid) - log.Println(writeString) - log.Println(storeWriteString) - if err = os.WriteFile("./"+cmdName+".bat", []byte(writeString+"\n"+storeWriteString), 0666); err != nil { - log.Fatal(err) - return - } - cmd := exec.Command("cmd", "/c", cmdName+".bat") - err = cmd.Start() - if err != nil { - fmt.Println("Error:", err) - return - } + err = utils.CmdCommand(ctx, name, args1...) + if err != nil { + log.Printf("cmd.Run() args1 failed with %s\n", err) + return } + //if runtime.GOOS == "linux" { + // // LINUX系统 + wireteString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=Unit --out=\"%s\" --query=\"{\\\"UniqueId\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", + mongoConfig.Link1, mongoConfig.Auth, userDir, req.SrcName) + writeString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=StoreComponent --out=\"%s\" --query=\"{\\\"_id\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", + mongoConfig.Link1, mongoConfig.Auth, storeDir, unit.Uid) + log.Println(wireteString) + log.Println(writeString) + // if err = os.WriteFile("./"+cmdName+".sh", []byte(wireteString+"\n"+writeString), 0666); err != nil { + // log.Println(err) + // return + // } + // cmd := exec.Command("sh", cmdName+".sh") + // var stdout, stderr bytes.Buffer + // cmd.Stdout = &stdout // 标准输出 + // cmd.Stderr = &stderr // 标准错误 + // err = cmd.Run() + // if err != nil { + // log.Printf("cmd.Run() failed with %s\n", err) + // return + // } + // outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) + // fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) + //} + // + //if runtime.GOOS == "windows" { + // // windows系统 + // writeString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=Unit --out=\"%s\" --query=\"{\\\"UniqueId\\\":%d}\" --jsonFormat=canonical --type=json", + // mongoConfig.Link1, mongoConfig.Auth, userDir, req.SrcName) + // storeWriteString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=StoreComponent --out=\"%s\" --query=\"{\\\"_id\\\":%d}\" --jsonFormat=canonical --type=json", + // mongoConfig.Link1, mongoConfig.Auth, storeDir, unit.Uid) + // log.Println(writeString) + // log.Println(storeWriteString) + // if err = os.WriteFile("./"+cmdName+".bat", []byte(writeString+"\n"+storeWriteString), 0666); err != nil { + // log.Println(err) + // return + // } + // cmd := exec.Command("cmd", "/c", cmdName+".bat") + // err = cmd.Start() + // if err != nil { + // fmt.Println("Error:", err) + // return + // } + //} res.Filename = filename res.StoreFilename = storeFilename }) @@ -693,7 +722,7 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe if err1 != nil { return res, err1 } - userDir := "./download/Unit" + fmt.Sprint(req.DestName) + ".json" + userDir := "./download/Unit" + fmt.Sprint(req.DestName) + fmt.Sprint(time.Now().Unix()) + ".json" srcUserDir := "./download/" + req.Filename writeByte, err1 := os.ReadFile(srcUserDir) if err1 != nil { @@ -720,7 +749,7 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe srcId = fmt.Sprint(UniqueId["$numberLong"]) } - userStoreDir := "./download/storeComponent" + fmt.Sprint(req.DestName) + ".json" + userStoreDir := "./download/storeComponent" + fmt.Sprint(req.DestName) + fmt.Sprint(time.Now().Unix()) + ".json" srcStoreDir := "./download/" + req.StoreFilename writeStoreByte, err1 := os.ReadFile(srcStoreDir) if err1 != nil { @@ -744,11 +773,12 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe writeStoreString := strings.ReplaceAll(gjson.MustEncodeString(v2), srcId, fmt.Sprint(destId)) writeUnitString = internal.ReplaceLastOccurrence(writeUnitString, srcUid, fmt.Sprint(req.DestName)) if err = os.WriteFile(userDir, []byte(writeUnitString), 0666); err != nil { - log.Fatal(err) + log.Println(err) return } + if err = os.WriteFile(userStoreDir, []byte(writeStoreString), 0666); err != nil { - log.Fatal(err) + log.Println(err) return } @@ -759,39 +789,75 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe log.Println("sh Unit: ", writeUnitCmd) log.Println("sh StoreComponent: ", writeStoreCmd) g.Try(ctx, func(ctx context.Context) { - cmdName := "getData" + fmt.Sprint(time.Now().Unix()) - if runtime.GOOS == "linux" { - // LINUX系统 - if err = os.WriteFile("./"+cmdName+".sh", []byte(writeUnitCmd+"\n"+writeStoreCmd), 0666); err != nil { - log.Fatal(err) - return - } - cmd := exec.Command("sh", cmdName+".sh") - var stdout, stderr bytes.Buffer - cmd.Stdout = &stdout // 标准输出 - cmd.Stderr = &stderr // 标准错误 - err = cmd.Run() - if err != nil { - log.Fatalf("cmd.Run() failed with %s\n", err) - return - } - outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) - fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) + name := "mongoimport" + args := []string{} + args1 := []string{} + args = append(args, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1)) + args = append(args, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth)) + args1 = append(args1, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1)) + args1 = append(args1, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth)) + args = append(args, "--collection=Unit") + args = append(args, fmt.Sprintf("--file=\"%s\"", userDir)) + args = append(args, "--type=json") + args = append(args, "--mode=upsert") + args1 = append(args1, "--collection=StoreComponent") + args1 = append(args1, fmt.Sprintf("--file=\"%s\"", userStoreDir)) + args1 = append(args1, "--type=json") + args1 = append(args1, "--mode=upsert") + + err = utils.CmdCommand(ctx, name, args...) + if err != nil { + log.Printf("cmd.Run() failed with %s\n", err) + return } - - if runtime.GOOS == "windows" { - // windows系统 - if err = os.WriteFile("./"+cmdName+".bat", []byte(writeUnitCmd+"\n"+writeStoreCmd), 0666); err != nil { - log.Fatal(err) - return - } - cmd := exec.Command("cmd", "/c", cmdName+".bat") - err = cmd.Start() - if err != nil { - fmt.Println("Error:", err) - return - } + err = utils.CmdCommand(ctx, name, args1...) + if err != nil { + log.Printf("cmd.Run() failed with %s\n", err) + return + } + err = os.Remove(userDir) + if err != nil { + log.Printf("os.Remove failed with %s\n", err) + return + } + err = os.Remove(userStoreDir) + if err != nil { + log.Printf("os.Remove failed with %s\n", err) + return } + //cmdName := "getData" + fmt.Sprint(time.Now().Unix()) + //if runtime.GOOS == "linux" { + // // LINUX系统 + // if err = os.WriteFile("./"+cmdName+".sh", []byte(writeUnitCmd+"\n"+writeStoreCmd), 0666); err != nil { + // log.Println(err) + // return + // } + // cmd := exec.Command("sh", cmdName+".sh") + // var stdout, stderr bytes.Buffer + // cmd.Stdout = &stdout // 标准输出 + // cmd.Stderr = &stderr // 标准错误 + // err = cmd.Run() + // if err != nil { + // log.Printf("cmd.Run() failed with %s\n", err) + // return + // } + // outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) + // fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) + //} + // + //if runtime.GOOS == "windows" { + // // windows系统 + // if err = os.WriteFile("./"+cmdName+".bat", []byte(writeUnitCmd+"\n"+writeStoreCmd), 0666); err != nil { + // log.Println(err) + // return + // } + // cmd := exec.Command("cmd", "/c", cmdName+".bat") + // err = cmd.Start() + // if err != nil { + // fmt.Println("Error:", err) + // return + // } + //} }) fmt.Println("UpdateUnit GetRoleDelta", req.DestName) return diff --git a/internal/serviceGame/pub.go b/internal/serviceGame/pub.go index e03c24e..26127f9 100644 --- a/internal/serviceGame/pub.go +++ b/internal/serviceGame/pub.go @@ -3,7 +3,10 @@ package serviceGame import ( "context" "github.com/gogf/gf/v2/frame/g" + "log" "tyj_admin/api/v1/game" + "tyj_admin/internal/dao" + "tyj_admin/internal/model/entity" "tyj_admin/internal/serviceGame/internal" ) @@ -15,6 +18,7 @@ type IGamePub interface { GetAuditMode(ctx context.Context, req *game.GetAuditModeReq) (res *game.GetAuditModeRes, err error) SetOpenId(ctx context.Context, req *game.SetOpenIdReq) (res *game.SetOpenIdRes, err error) GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (res *game.GetOpenIdRes, err error) + GetServerConfig(ctx context.Context, req *game.GetServerConfigReq) (res *game.GetServerConfigRes, err error) } type gamePubImpl struct { @@ -94,3 +98,43 @@ func (c *gamePubImpl) GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (re //res.State = 1 return } + +func (c *gamePubImpl) GetServerConfig(ctx context.Context, req *game.GetServerConfigReq) (res *game.GetServerConfigRes, err error) { + res = new(game.GetServerConfigRes) + err1 := g.Try(ctx, func(ctx context.Context) { + general := []entity.GameServerJsonGeneral{} + err := dao.GameServerJsonGeneral.Ctx(ctx).Where("id=?", 1).Scan(&general) + if err != nil { + log.Println(err) + return + } + + loginUrl := []entity.GameLoginUrl{} + err = dao.GameLoginUrl.Ctx(ctx).Where("id=?", req.ServerId).Scan(&loginUrl) + if err != nil { + log.Println(err) + return + } + if len(general) == 0 || len(loginUrl) == 0 { + log.Println("为查询到服务器配置!") + return + } + + res.Id = loginUrl[0].Id + res.GameDifficulty = loginUrl[0].Difficulty + res.CreateTime = loginUrl[0].CreateTime.Unix() + res.GameDbUrl = loginUrl[0].GameDbUrl + res.GameDbName = loginUrl[0].GameDbName + res.Platform = loginUrl[0].Platform + res.InnerIp = loginUrl[0].InnerIp + res.SdkAddress = general[0].SdkAddress + res.UniqueAddress = general[0].UniqueAddress + res.IdentityCheckAddress = general[0].IdentityCheckAddress + res.RechargeWhiteListIps = general[0].RechargeWhiteListIps + res.GmWhiteListUrl = general[0].GmWhiteListUrl + res.BackstageRechargeUrl = general[0].BackstageRechargeUrl + }) + + log.Println(err1) + return +} diff --git a/utils/util.go b/utils/util.go index d9499e5..c9cef10 100644 --- a/utils/util.go +++ b/utils/util.go @@ -162,13 +162,13 @@ func CheckFileIsExist(filename string) bool { return exist } -func CmdCommand(ctx context.Context, name string, args ...string) { - g.Try(ctx, func(ctx context.Context) { +func CmdCommand(ctx context.Context, name string, args ...string) (err error) { + err = g.Try(ctx, func(ctx context.Context) { cmd := exec.Command(name, args...) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout // 标准输出 cmd.Stderr = &stderr // 标准错误 - err := cmd.Run() + err = cmd.Run() if err != nil { log.Printf("cmd.Run() failed with %s\n", err) return @@ -176,4 +176,5 @@ func CmdCommand(ctx context.Context, name string, args ...string) { outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) }) + return }