Browse Source

server Json,OperLog

master
linquan 4 months ago
parent
commit
63667de00e
  1. 23
      api/v1/game/ccd.go
  2. 23
      api/v1/game/pub.go
  3. 5
      internal/controller/game_login_url.go
  4. 5
      internal/controller/game_pub.go
  5. 27
      internal/dao/game_router.go
  6. 27
      internal/dao/game_server_json.go
  7. 27
      internal/dao/game_server_json_general.go
  8. 14
      internal/dao/internal/game_login_url.go
  9. 91
      internal/dao/internal/game_router.go
  10. 83
      internal/dao/internal/game_server_json.go
  11. 85
      internal/dao/internal/game_server_json_general.go
  12. 8
      internal/model/do/game_login_url.go
  13. 24
      internal/model/do/game_router.go
  14. 21
      internal/model/do/game_server_json.go
  15. 21
      internal/model/do/game_server_json_general.go
  16. 35
      internal/model/entity/game_login_url.go
  17. 19
      internal/model/entity/game_router.go
  18. 19
      internal/model/entity/game_server_json.go
  19. 16
      internal/model/entity/game_server_json_general.go
  20. 16
      internal/service/middleware.go
  21. 29
      internal/serviceGame/loginUrl.go
  22. 228
      internal/serviceGame/manage.go
  23. 44
      internal/serviceGame/pub.go
  24. 7
      utils/util.go

23
api/v1/game/ccd.go

@ -57,6 +57,15 @@ type GetLoginUrlRes struct {
Total int `json:"total"` 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 { type GetAllLoginUrlReq struct {
g.Meta `path:"/loginUrl/getAllLoginUrl" tags:"登录地址" method:"post" summary:"allLoginUrl"` g.Meta `path:"/loginUrl/getAllLoginUrl" tags:"登录地址" method:"post" summary:"allLoginUrl"`
} }
@ -78,6 +87,20 @@ type AddLoginUrlReq struct {
type AddLoginUrlRes 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 { type DelLoginUrlReq struct {
g.Meta `path:"/loginUrl/delLoginUrl" tags:"登录地址" method:"post" summary:"删除loginUrl"` g.Meta `path:"/loginUrl/delLoginUrl" tags:"登录地址" method:"post" summary:"删除loginUrl"`
Id uint64 `p:"id"` Id uint64 `p:"id"`

23
api/v1/game/pub.go

@ -39,6 +39,7 @@ type LoginUrlData struct {
Last int `json:"last" description:"上次登录标识,1-登录"` Last int `json:"last" description:"上次登录标识,1-登录"`
Scale int `json:"scale" description:"玩家规模等级"` Scale int `json:"scale" description:"玩家规模等级"`
AccountName string `json:"accountName" description:"玩家名称"` AccountName string `json:"accountName" description:"玩家名称"`
CreateTime int64 `json:"createTime" description:"创建时间"`
} }
type GetGameLoginUrlRes struct { type GetGameLoginUrlRes struct {
@ -225,3 +226,25 @@ type GetOpenIdRes struct {
g.Meta `mime:"application/json"` g.Meta `mime:"application/json"`
State int `json:"state"` 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:""`
}

5
internal/controller/game_login_url.go

@ -17,6 +17,11 @@ func (c *loginUrlController) Get(ctx context.Context, req *game.GetLoginUrlReq)
return 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) { func (c *loginUrlController) GetAll(ctx context.Context, req *game.GetAllLoginUrlReq) (res *game.GetAllLoginUrlRes, err error) {
res, err = serviceGame.GameLoginUrl().GetAllLoginUrl(ctx, req) res, err = serviceGame.GameLoginUrl().GetAllLoginUrl(ctx, req)
return return

5
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) res, err = serviceGame.GameManage().SetGmToClient(ctx, req)
return return
} }
func (c *pubController) GetServerConfig(ctx context.Context, req *game.GetServerConfigReq) (res *game.GetServerConfigRes, err error) {
res, err = serviceGame.GamePub().GetServerConfig(ctx, req)
return
}

27
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.

27
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.

27
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.

14
internal/dao/internal/game_login_url.go

@ -32,6 +32,13 @@ type GameLoginUrlColumns struct {
Area string // 区服 Area string // 区服
IsShow string // 1-可见,0-不可见 IsShow string // 1-可见,0-不可见
Channel string // 固定渠道 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. // gameLoginUrlColumns holds the columns for table game_login_url.
@ -48,6 +55,13 @@ var gameLoginUrlColumns = GameLoginUrlColumns{
Area: "area", Area: "area",
IsShow: "isShow", IsShow: "isShow",
Channel: "channel", 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. // NewGameLoginUrlDao creates and returns a new DAO object for table data access.

91
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)
}

83
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)
}

85
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)
}

8
internal/model/do/game_login_url.go

@ -6,6 +6,7 @@ package do
import ( import (
"github.com/gogf/gf/v2/frame/g" "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. // 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{} // 区服 Area interface{} // 区服
IsShow interface{} // 1-可见,0-不可见 IsShow interface{} // 1-可见,0-不可见
Channel interface{} // 固定渠道 Channel interface{} // 固定渠道
CDate *gtime.Time // 创建时间-用于排序
GameDbUrl interface{} // 数据库地址
GameDbName interface{} // 数据库名称
Platform interface{} // 平台-充值
InnerIp interface{} // 内外地址
CreateTime *gtime.Time // 开服时间-用于服务器时间
Remark interface{} // 备注名称
} }

24
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{} //
}

21
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 //
}

21
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{} //
}

35
internal/model/entity/game_login_url.go

@ -4,18 +4,29 @@
package entity package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// GameLoginUrl is the golang structure for table game_login_url. // GameLoginUrl is the golang structure for table game_login_url.
type GameLoginUrl struct { type GameLoginUrl struct {
Id int `json:"id" description:"100+为外网id"` Id int `json:"id" description:"100+为外网id"`
Host string `json:"host" description:""` Host string `json:"host" description:""`
Port int `json:"port" description:""` Port int `json:"port" description:""`
State int `json:"state" description:"服务器状态,1-正常,2-维护,3-白名单ip优先加渠道,4-黑名单渠道优先"` State int `json:"state" description:"服务器状态,1-正常,2-维护,3-白名单ip优先加渠道,4-黑名单渠道优先"`
Recommend int `json:"recommend" description:"推荐,1-推荐,0-不推荐"` Recommend int `json:"recommend" description:"推荐,1-推荐,0-不推荐"`
Name string `json:"name" description:"名称"` Name string `json:"name" description:"名称"`
Difficulty int `json:"difficulty" description:"难度,1-简单,2-困难"` Difficulty int `json:"difficulty" description:"难度,1-简单,2-困难"`
RechargeHost string `json:"rechargeHost" description:""` RechargeHost string `json:"rechargeHost" description:""`
RechargePort int `json:"rechargePort" description:""` RechargePort int `json:"rechargePort" description:""`
Area int `json:"area" description:"区服"` Area int `json:"area" description:"区服"`
IsShow int `json:"isShow" description:"1-可见,0-不可见"` IsShow int `json:"isShow" description:"1-可见,0-不可见"`
Channel string `json:"channel" description:"固定渠道"` 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:"备注名称"`
} }

19
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:""`
}

19
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:""`
}

16
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:""`
}

16
internal/service/middleware.go

@ -15,6 +15,7 @@ import (
"github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gconv"
"log" "log"
"time" "time"
"tyj_admin/internal/consts"
"tyj_admin/internal/dao" "tyj_admin/internal/dao"
"tyj_admin/internal/model" "tyj_admin/internal/model"
"tyj_admin/library/libResponse" "tyj_admin/library/libResponse"
@ -144,6 +145,13 @@ func (s *middlewareImpl) Auth(r *ghttp.Request) {
// 操作日志 处理中间件 // 操作日志 处理中间件
func (s *middlewareImpl) OperLog(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() ctx := r.GetCtx()
//获取登陆用户id //获取登陆用户id
user := Context().GetLoginUser(ctx) user := Context().GetLoginUser(ctx)
@ -153,9 +161,9 @@ func (s *middlewareImpl) OperLog(r *ghttp.Request) {
} }
dao.SysOperLog.Ctx(ctx).Insert(g.Map{ 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().BusinessType: 0,
dao.SysOperLog.Columns().Method: r.URL, dao.SysOperLog.Columns().Method: r.Method,
dao.SysOperLog.Columns().RequestMethod: r.Method, dao.SysOperLog.Columns().RequestMethod: r.Method,
dao.SysOperLog.Columns().OperatorType: 0, dao.SysOperLog.Columns().OperatorType: 0,
dao.SysOperLog.Columns().OperName: userName, 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().OperIp: r.GetClientIp(),
dao.SysOperLog.Columns().OperLocation: r.RemoteAddr, dao.SysOperLog.Columns().OperLocation: r.RemoteAddr,
dao.SysOperLog.Columns().OperParam: r.URL.RawQuery, 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()
} }

29
internal/serviceGame/loginUrl.go

@ -19,6 +19,8 @@ import (
type IGameLoginUrl interface { type IGameLoginUrl interface {
GetLoginUrl(ctx context.Context, req *game.GetLoginUrlReq) (res *game.GetLoginUrlRes, err error) 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) GetAllLoginUrl(ctx context.Context, req *game.GetAllLoginUrlReq) (res *game.GetAllLoginUrlRes, err error)
AddLoginUrl(ctx context.Context, req *game.AddLoginUrlReq) (res *game.AddLoginUrlRes, 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) 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 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) { func (c *gameLoginUrlImpl) GetAllLoginUrl(ctx context.Context, req *game.GetAllLoginUrlReq) (res *game.GetAllLoginUrlRes, err error) {
g.Try(ctx, func(ctx context.Context) { g.Try(ctx, func(ctx context.Context) {
res = new(game.GetAllLoginUrlRes) 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, 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 data.State == consts.Login_URL_STATE_WHITE {
if utils.ContainsWhiteList(list, ip) || utils.ContainsWhiteList(list, req.Channel) { if utils.ContainsWhiteList(list, ip) || utils.ContainsWhiteList(list, req.Channel) {
data.State = consts.Login_URL_STATE_NORMAL data.State = consts.Login_URL_STATE_NORMAL

228
internal/serviceGame/manage.go

@ -1,7 +1,6 @@
package serviceGame package serviceGame
import ( import (
"bytes"
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
@ -12,8 +11,6 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"log" "log"
"os" "os"
"os/exec"
"runtime"
"strings" "strings"
"time" "time"
"tyj_admin/api/v1/game" "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" storeFilename := "storeComponent" + fmt.Sprint(req.SrcName) + ".json"
userDir := "./download/" + filename userDir := "./download/" + filename
storeDir := "./download/" + storeFilename storeDir := "./download/" + storeFilename
cmdName := "getData" + fmt.Sprint(time.Now().Unix()) //cmdName := "getData" + fmt.Sprint(time.Now().Unix())
g.Try(ctx, func(ctx context.Context) { g.Try(ctx, func(ctx context.Context) {
if runtime.GOOS == "linux" { name := "mongoexport"
// LINUX系统 args := []string{}
wireteString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=Unit --out=\"%s\" --query=\"{\\\"UniqueId\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", args1 := []string{}
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", args = append(args, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1))
mongoConfig.Link1, mongoConfig.Auth, storeDir, unit.Uid) args = append(args, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth))
log.Println(wireteString) args1 = append(args1, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1))
log.Println(writeString) args1 = append(args1, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth))
if err = os.WriteFile("./"+cmdName+".sh", []byte(wireteString+"\n"+writeString), 0666); err != nil { args = append(args, "--collection=Unit")
log.Fatal(err) args = append(args, "--jsonArray")
return args = append(args, fmt.Sprintf("--out=\"%s\"", userDir))
} args = append(args, fmt.Sprintf("--query=\"{\\\"UniqueId\\\":%d}\"", req.SrcName))
cmd := exec.Command("sh", cmdName+".sh") args = append(args, "--jsonFormat=canonical")
var stdout, stderr bytes.Buffer args = append(args, "--type=json")
cmd.Stdout = &stdout // 标准输出 args1 = append(args1, "--collection=StoreComponent")
cmd.Stderr = &stderr // 标准错误 args1 = append(args1, "--jsonArray")
err = cmd.Run() args1 = append(args1, fmt.Sprintf("--out=\"%s\"", storeDir))
if err != nil { args1 = append(args1, fmt.Sprintf("--query=\"{\\\"_id\\\":%d}\"", unit.Uid))
log.Fatalf("cmd.Run() failed with %s\n", err) args1 = append(args1, "--jsonFormat=canonical")
return args1 = append(args1, "--type=json")
}
outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) err = utils.CmdCommand(ctx, name, args...)
fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) if err != nil {
log.Printf("cmd.Run() args failed with %s\n", err)
return
} }
err = utils.CmdCommand(ctx, name, args1...)
if runtime.GOOS == "windows" { if err != nil {
// windows系统 log.Printf("cmd.Run() args1 failed with %s\n", err)
writeString := fmt.Sprintf("mongoexport --uri=\"%s\" --authenticationDatabase=%s --collection=Unit --out=\"%s\" --query=\"{\\\"UniqueId\\\":%d}\" --jsonArray --jsonFormat=canonical --type=json", return
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
}
} }
//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.Filename = filename
res.StoreFilename = storeFilename res.StoreFilename = storeFilename
}) })
@ -693,7 +722,7 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe
if err1 != nil { if err1 != nil {
return res, err1 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 srcUserDir := "./download/" + req.Filename
writeByte, err1 := os.ReadFile(srcUserDir) writeByte, err1 := os.ReadFile(srcUserDir)
if err1 != nil { if err1 != nil {
@ -720,7 +749,7 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe
srcId = fmt.Sprint(UniqueId["$numberLong"]) 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 srcStoreDir := "./download/" + req.StoreFilename
writeStoreByte, err1 := os.ReadFile(srcStoreDir) writeStoreByte, err1 := os.ReadFile(srcStoreDir)
if err1 != nil { 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)) writeStoreString := strings.ReplaceAll(gjson.MustEncodeString(v2), srcId, fmt.Sprint(destId))
writeUnitString = internal.ReplaceLastOccurrence(writeUnitString, srcUid, fmt.Sprint(req.DestName)) writeUnitString = internal.ReplaceLastOccurrence(writeUnitString, srcUid, fmt.Sprint(req.DestName))
if err = os.WriteFile(userDir, []byte(writeUnitString), 0666); err != nil { if err = os.WriteFile(userDir, []byte(writeUnitString), 0666); err != nil {
log.Fatal(err) log.Println(err)
return return
} }
if err = os.WriteFile(userStoreDir, []byte(writeStoreString), 0666); err != nil { if err = os.WriteFile(userStoreDir, []byte(writeStoreString), 0666); err != nil {
log.Fatal(err) log.Println(err)
return return
} }
@ -759,39 +789,75 @@ func (ga *gameManageImpl) UpdateUnit(ctx context.Context, req *game.UpdateUnitRe
log.Println("sh Unit: ", writeUnitCmd) log.Println("sh Unit: ", writeUnitCmd)
log.Println("sh StoreComponent: ", writeStoreCmd) log.Println("sh StoreComponent: ", writeStoreCmd)
g.Try(ctx, func(ctx context.Context) { g.Try(ctx, func(ctx context.Context) {
cmdName := "getData" + fmt.Sprint(time.Now().Unix()) name := "mongoimport"
if runtime.GOOS == "linux" { args := []string{}
// LINUX系统 args1 := []string{}
if err = os.WriteFile("./"+cmdName+".sh", []byte(writeUnitCmd+"\n"+writeStoreCmd), 0666); err != nil { args = append(args, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1))
log.Fatal(err) args = append(args, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth))
return args1 = append(args1, fmt.Sprintf("--uri=\"%s\"", mongoConfig.Link1))
} args1 = append(args1, fmt.Sprintf("--authenticationDatabase=%s", mongoConfig.Auth))
cmd := exec.Command("sh", cmdName+".sh") args = append(args, "--collection=Unit")
var stdout, stderr bytes.Buffer args = append(args, fmt.Sprintf("--file=\"%s\"", userDir))
cmd.Stdout = &stdout // 标准输出 args = append(args, "--type=json")
cmd.Stderr = &stderr // 标准错误 args = append(args, "--mode=upsert")
err = cmd.Run() args1 = append(args1, "--collection=StoreComponent")
if err != nil { args1 = append(args1, fmt.Sprintf("--file=\"%s\"", userStoreDir))
log.Fatalf("cmd.Run() failed with %s\n", err) args1 = append(args1, "--type=json")
return args1 = append(args1, "--mode=upsert")
}
outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) err = utils.CmdCommand(ctx, name, args...)
fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) if err != nil {
log.Printf("cmd.Run() failed with %s\n", err)
return
} }
err = utils.CmdCommand(ctx, name, args1...)
if runtime.GOOS == "windows" { if err != nil {
// windows系统 log.Printf("cmd.Run() failed with %s\n", err)
if err = os.WriteFile("./"+cmdName+".bat", []byte(writeUnitCmd+"\n"+writeStoreCmd), 0666); err != nil { return
log.Fatal(err) }
return err = os.Remove(userDir)
} if err != nil {
cmd := exec.Command("cmd", "/c", cmdName+".bat") log.Printf("os.Remove failed with %s\n", err)
err = cmd.Start() return
if err != nil { }
fmt.Println("Error:", err) err = os.Remove(userStoreDir)
return 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) fmt.Println("UpdateUnit GetRoleDelta", req.DestName)
return return

44
internal/serviceGame/pub.go

@ -3,7 +3,10 @@ package serviceGame
import ( import (
"context" "context"
"github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/frame/g"
"log"
"tyj_admin/api/v1/game" "tyj_admin/api/v1/game"
"tyj_admin/internal/dao"
"tyj_admin/internal/model/entity"
"tyj_admin/internal/serviceGame/internal" "tyj_admin/internal/serviceGame/internal"
) )
@ -15,6 +18,7 @@ type IGamePub interface {
GetAuditMode(ctx context.Context, req *game.GetAuditModeReq) (res *game.GetAuditModeRes, err error) GetAuditMode(ctx context.Context, req *game.GetAuditModeReq) (res *game.GetAuditModeRes, err error)
SetOpenId(ctx context.Context, req *game.SetOpenIdReq) (res *game.SetOpenIdRes, 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) 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 { type gamePubImpl struct {
@ -94,3 +98,43 @@ func (c *gamePubImpl) GetOpenId(ctx context.Context, req *game.GetOpenIdReq) (re
//res.State = 1 //res.State = 1
return 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
}

7
utils/util.go

@ -162,13 +162,13 @@ func CheckFileIsExist(filename string) bool {
return exist return exist
} }
func CmdCommand(ctx context.Context, name string, args ...string) { func CmdCommand(ctx context.Context, name string, args ...string) (err error) {
g.Try(ctx, func(ctx context.Context) { err = g.Try(ctx, func(ctx context.Context) {
cmd := exec.Command(name, args...) cmd := exec.Command(name, args...)
var stdout, stderr bytes.Buffer var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout // 标准输出 cmd.Stdout = &stdout // 标准输出
cmd.Stderr = &stderr // 标准错误 cmd.Stderr = &stderr // 标准错误
err := cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
log.Printf("cmd.Run() failed with %s\n", err) log.Printf("cmd.Run() failed with %s\n", err)
return return
@ -176,4 +176,5 @@ func CmdCommand(ctx context.Context, name string, args ...string) {
outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes()) outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes())
fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr) fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr)
}) })
return
} }

Loading…
Cancel
Save