From 7449f77bb473c825d5363f3afb6cfde1e17aedd5 Mon Sep 17 00:00:00 2001 From: linquan <349589071@qq.com> Date: Thu, 22 Jan 2026 17:24:27 +0800 Subject: [PATCH] =?UTF-8?q?activity,=20loginUrl=E6=96=B0=E5=A2=9Ebelong,?= =?UTF-8?q?=20=E5=9C=A8=E7=BA=BF=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9Ebelong?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8,=20=E5=B9=BF=E5=91=8A=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/game/game_activity.go | 48 +++++++ internal/controller/game_activity.go | 33 +++++ .../{game_Bazaar.go => game_bazaar.go} | 0 .../{game_Version.go => game_version.go} | 0 internal/dao/csj_advertisement.go | 27 ++++ internal/dao/game_activity_time.go | 27 ++++ internal/dao/internal/csj_advertisement.go | 79 +++++++++++ internal/dao/internal/game_activity_time.go | 87 ++++++++++++ internal/dao/internal/game_login_url.go | 2 +- internal/model/do/csj_advertisement.go | 18 +++ internal/model/do/game_activity_time.go | 23 +++ internal/model/do/game_login_url.go | 2 +- internal/model/entity/csj_advertisement.go | 13 ++ internal/model/entity/game_activity_time.go | 21 +++ internal/router/router.go | 1 + internal/serviceGame/ccd.go | 2 +- internal/serviceGame/game_activity.go | 131 ++++++++++++++++++ .../serviceGame/internal/game_activity.go | 31 +++++ internal/serviceGame/internal/online.go | 12 ++ 19 files changed, 554 insertions(+), 3 deletions(-) create mode 100644 api/v1/game/game_activity.go create mode 100644 internal/controller/game_activity.go rename internal/controller/{game_Bazaar.go => game_bazaar.go} (100%) rename internal/controller/{game_Version.go => game_version.go} (100%) create mode 100644 internal/dao/csj_advertisement.go create mode 100644 internal/dao/game_activity_time.go create mode 100644 internal/dao/internal/csj_advertisement.go create mode 100644 internal/dao/internal/game_activity_time.go create mode 100644 internal/model/do/csj_advertisement.go create mode 100644 internal/model/do/game_activity_time.go create mode 100644 internal/model/entity/csj_advertisement.go create mode 100644 internal/model/entity/game_activity_time.go create mode 100644 internal/serviceGame/game_activity.go create mode 100644 internal/serviceGame/internal/game_activity.go diff --git a/api/v1/game/game_activity.go b/api/v1/game/game_activity.go new file mode 100644 index 0000000..7c7e9d0 --- /dev/null +++ b/api/v1/game/game_activity.go @@ -0,0 +1,48 @@ +package game + +import ( + "github.com/gogf/gf/v2/frame/g" + "tyj_admin/api/v1/common" + "tyj_admin/internal/model/entity" +) + +type GetActivityConfigsReq struct { + g.Meta `path:"/gameActivity/list" tags:"gameActivity" method:"get" summary:"获取"` + common.PageReq + ServerId int32 `p:"serverId"` +} +type GetActivityConfigsRes struct { + g.Meta `mime:"application/json"` + List []entity.GameActivityTime `json:"list"` + common.ListRes +} + +type GetAllGameActivityReq struct { + g.Meta `path:"/gameActivity/get" tags:"gameActivity" method:"get" summary:"获取"` + ServerId int32 `p:"serverId"` +} +type GetAllGameActivityRes struct { + g.Meta `mime:"application/json"` + List []entity.GameActivityTime `json:"list"` +} + +type AddActivityConfigReq struct { + g.Meta `path:"/gameActivity/add" tags:"gameActivity" method:"get" summary:"添加gameActivity"` + Id int32 `p:"id"` + ServerId int32 `p:"serverId"` + ConfigId int32 `p:"configId"` + PreviewTime string `p:"previewTime"` + StartTime string `p:"startTime"` + EndTime string `p:"endTime"` + CloseTime string `p:"closeTime"` + Remark string `p:"remark"` +} +type AddActivityConfigRes struct { +} + +type DelActivityConfigReq struct { + g.Meta `path:"/gameActivity/del" tags:"gameActivity" method:"get" summary:"删除热更地址"` + Id int32 `p:"id"` +} +type DelActivityConfigRes struct { +} diff --git a/internal/controller/game_activity.go b/internal/controller/game_activity.go new file mode 100644 index 0000000..3b51f1a --- /dev/null +++ b/internal/controller/game_activity.go @@ -0,0 +1,33 @@ +package controller + +import ( + "context" + "tyj_admin/api/v1/game" + "tyj_admin/internal/serviceGame" +) + +var GameActivity = activityController{} + +type activityController struct { + BaseController +} + +func (c *activityController) GetGameActivity(ctx context.Context, req *game.GetActivityConfigsReq) (res *game.GetActivityConfigsRes, err error) { + res, err = serviceGame.GameActivity().GetGameActivity(ctx, req) + return +} + +func (c *activityController) AddGameActivity(ctx context.Context, req *game.AddActivityConfigReq) (res *game.AddActivityConfigRes, err error) { + res, err = serviceGame.GameActivity().AddGameActivity(ctx, req) + return +} + +func (c *activityController) DelGameActivity(ctx context.Context, req *game.DelActivityConfigReq) (res *game.DelActivityConfigRes, err error) { + res, err = serviceGame.GameActivity().DelGameActivity(ctx, req) + return +} + +func (c *serverController) GetAllGameActivity(ctx context.Context, req *game.GetAllGameActivityReq) (res *game.GetAllGameActivityRes, err error) { + res, err = serviceGame.GameActivity().GetAllGameActivity(ctx, req) + return +} diff --git a/internal/controller/game_Bazaar.go b/internal/controller/game_bazaar.go similarity index 100% rename from internal/controller/game_Bazaar.go rename to internal/controller/game_bazaar.go diff --git a/internal/controller/game_Version.go b/internal/controller/game_version.go similarity index 100% rename from internal/controller/game_Version.go rename to internal/controller/game_version.go diff --git a/internal/dao/csj_advertisement.go b/internal/dao/csj_advertisement.go new file mode 100644 index 0000000..b44b940 --- /dev/null +++ b/internal/dao/csj_advertisement.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" +) + +// internalCsjAdvertisementDao is internal type for wrapping internal DAO implements. +type internalCsjAdvertisementDao = *internal.CsjAdvertisementDao + +// csjAdvertisementDao is the data access object for table csj_advertisement. +// You can define custom methods on it to extend its functionality as you wish. +type csjAdvertisementDao struct { + internalCsjAdvertisementDao +} + +var ( + // CsjAdvertisement is globally public accessible object for table csj_advertisement operations. + CsjAdvertisement = csjAdvertisementDao{ + internal.NewCsjAdvertisementDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/game_activity_time.go b/internal/dao/game_activity_time.go new file mode 100644 index 0000000..7278134 --- /dev/null +++ b/internal/dao/game_activity_time.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" +) + +// internalGameActivityTimeDao is internal type for wrapping internal DAO implements. +type internalGameActivityTimeDao = *internal.GameActivityTimeDao + +// gameActivityTimeDao is the data access object for table game_activity_time. +// You can define custom methods on it to extend its functionality as you wish. +type gameActivityTimeDao struct { + internalGameActivityTimeDao +} + +var ( + // GameActivityTime is globally public accessible object for table game_activity_time operations. + GameActivityTime = gameActivityTimeDao{ + internal.NewGameActivityTimeDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/internal/csj_advertisement.go b/internal/dao/internal/csj_advertisement.go new file mode 100644 index 0000000..6a507b7 --- /dev/null +++ b/internal/dao/internal/csj_advertisement.go @@ -0,0 +1,79 @@ +// ========================================================================== +// 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" +) + +// CsjAdvertisementDao is the data access object for table csj_advertisement. +type CsjAdvertisementDao 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 CsjAdvertisementColumns // columns contains all the column names of Table for convenient usage. +} + +// CsjAdvertisementColumns defines and stores column names for table csj_advertisement. +type CsjAdvertisementColumns struct { + Id string // + PrimeRit string // + MediationRit string // + MKey string // +} + +// csjAdvertisementColumns holds the columns for table csj_advertisement. +var csjAdvertisementColumns = CsjAdvertisementColumns{ + Id: "id", + PrimeRit: "prime_rit", + MediationRit: "mediation_rit", + MKey: "m_key", +} + +// NewCsjAdvertisementDao creates and returns a new DAO object for table data access. +func NewCsjAdvertisementDao() *CsjAdvertisementDao { + return &CsjAdvertisementDao{ + group: "default", + table: "csj_advertisement", + columns: csjAdvertisementColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *CsjAdvertisementDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *CsjAdvertisementDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *CsjAdvertisementDao) Columns() CsjAdvertisementColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *CsjAdvertisementDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *CsjAdvertisementDao) 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 *CsjAdvertisementDao) 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_activity_time.go b/internal/dao/internal/game_activity_time.go new file mode 100644 index 0000000..9772c36 --- /dev/null +++ b/internal/dao/internal/game_activity_time.go @@ -0,0 +1,87 @@ +// ========================================================================== +// 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" +) + +// GameActivityTimeDao is the data access object for table game_activity_time. +type GameActivityTimeDao 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 GameActivityTimeColumns // columns contains all the column names of Table for convenient usage. +} + +// GameActivityTimeColumns defines and stores column names for table game_activity_time. +type GameActivityTimeColumns struct { + Id string // + PreviewTime string // + StartTime string // + EndTime string // + CloseTime string // + ServerId string // + ConfigId string // + Remark string // +} + +// gameActivityTimeColumns holds the columns for table game_activity_time. +var gameActivityTimeColumns = GameActivityTimeColumns{ + Id: "id", + PreviewTime: "preview_time", + StartTime: "start_time", + EndTime: "end_time", + CloseTime: "close_time", + ServerId: "server_id", + ConfigId: "config_id", + Remark: "remark", +} + +// NewGameActivityTimeDao creates and returns a new DAO object for table data access. +func NewGameActivityTimeDao() *GameActivityTimeDao { + return &GameActivityTimeDao{ + group: "default", + table: "game_activity_time", + columns: gameActivityTimeColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *GameActivityTimeDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *GameActivityTimeDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *GameActivityTimeDao) Columns() GameActivityTimeColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *GameActivityTimeDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *GameActivityTimeDao) 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 *GameActivityTimeDao) 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_login_url.go b/internal/dao/internal/game_login_url.go index 0902d79..ec81804 100644 --- a/internal/dao/internal/game_login_url.go +++ b/internal/dao/internal/game_login_url.go @@ -41,7 +41,7 @@ type GameLoginUrlColumns struct { Remark string // 备注名称 IsNew string // Sort string // 后台排序 - Belong string // 附属服务器 + Belong string // 附庸服务器 } // gameLoginUrlColumns holds the columns for table game_login_url. diff --git a/internal/model/do/csj_advertisement.go b/internal/model/do/csj_advertisement.go new file mode 100644 index 0000000..0d327a5 --- /dev/null +++ b/internal/model/do/csj_advertisement.go @@ -0,0 +1,18 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// CsjAdvertisement is the golang structure of table csj_advertisement for DAO operations like Where/Data. +type CsjAdvertisement struct { + g.Meta `orm:"table:csj_advertisement, do:true"` + Id interface{} // + PrimeRit interface{} // + MediationRit interface{} // + MKey interface{} // +} diff --git a/internal/model/do/game_activity_time.go b/internal/model/do/game_activity_time.go new file mode 100644 index 0000000..ca260d5 --- /dev/null +++ b/internal/model/do/game_activity_time.go @@ -0,0 +1,23 @@ +// ================================================================================= +// 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" +) + +// GameActivityTime is the golang structure of table game_activity_time for DAO operations like Where/Data. +type GameActivityTime struct { + g.Meta `orm:"table:game_activity_time, do:true"` + Id interface{} // + PreviewTime *gtime.Time // + StartTime *gtime.Time // + EndTime *gtime.Time // + CloseTime *gtime.Time // + ServerId interface{} // + ConfigId interface{} // + Remark interface{} // +} diff --git a/internal/model/do/game_login_url.go b/internal/model/do/game_login_url.go index 20d0ce5..20ccab9 100644 --- a/internal/model/do/game_login_url.go +++ b/internal/model/do/game_login_url.go @@ -33,5 +33,5 @@ type GameLoginUrl struct { Remark interface{} // 备注名称 IsNew interface{} // Sort interface{} // 后台排序 - Belong interface{} // 附属服务器 + Belong interface{} // 附庸服务器 } diff --git a/internal/model/entity/csj_advertisement.go b/internal/model/entity/csj_advertisement.go new file mode 100644 index 0000000..64c5f63 --- /dev/null +++ b/internal/model/entity/csj_advertisement.go @@ -0,0 +1,13 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// CsjAdvertisement is the golang structure for table csj_advertisement. +type CsjAdvertisement struct { + Id int `json:"id" description:""` + PrimeRit string `json:"primeRit" description:""` + MediationRit string `json:"mediationRit" description:""` + MKey string `json:"mKey" description:""` +} diff --git a/internal/model/entity/game_activity_time.go b/internal/model/entity/game_activity_time.go new file mode 100644 index 0000000..a56d1b5 --- /dev/null +++ b/internal/model/entity/game_activity_time.go @@ -0,0 +1,21 @@ +// ================================================================================= +// Code generated by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// GameActivityTime is the golang structure for table game_activity_time. +type GameActivityTime struct { + Id int `json:"id" description:""` + PreviewTime *gtime.Time `json:"previewTime" description:""` + StartTime *gtime.Time `json:"startTime" description:""` + EndTime *gtime.Time `json:"endTime" description:""` + CloseTime *gtime.Time `json:"closeTime" description:""` + ServerId int `json:"serverId" description:""` + ConfigId int `json:"configId" description:""` + Remark string `json:"remark" description:""` +} diff --git a/internal/router/router.go b/internal/router/router.go index 946f00e..ac4d437 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -174,6 +174,7 @@ func GameBindController(group *ghttp.RouterGroup) { controller.GameBug, controller.GameChannel, controller.GameBattlePass, + controller.GameActivity, ) }) } diff --git a/internal/serviceGame/ccd.go b/internal/serviceGame/ccd.go index bdb9888..fd93ee5 100644 --- a/internal/serviceGame/ccd.go +++ b/internal/serviceGame/ccd.go @@ -129,7 +129,7 @@ func (c *gameCCDImpl) GetGameCCD(ctx context.Context, req *game.GetGameCCDReq) ( } res.EnableAccountLogin = 0 res.EnableHotfix = 1 - res.EnableAds = 0 + res.EnableAds = 1 err = g.Try(ctx, func(ctx context.Context) { if internal.GetEnableHotfix(ctx, req.ChannelType+req.Version) != "" { data, _ := strconv.Atoi(internal.GetEnableHotfix(ctx, req.ChannelType+req.Version)) diff --git a/internal/serviceGame/game_activity.go b/internal/serviceGame/game_activity.go new file mode 100644 index 0000000..fd5ee40 --- /dev/null +++ b/internal/serviceGame/game_activity.go @@ -0,0 +1,131 @@ +package serviceGame + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" + "tyj_admin/api/v1/game" + "tyj_admin/internal/dao" + "tyj_admin/internal/model/do" + "tyj_admin/internal/model/entity" + "tyj_admin/library/liberr" +) + +type IGameActivity interface { + GetGameActivity(ctx context.Context, req *game.GetActivityConfigsReq) (res *game.GetActivityConfigsRes, err error) + AddGameActivity(ctx context.Context, req *game.AddActivityConfigReq) (res *game.AddActivityConfigRes, err error) + DelGameActivity(ctx context.Context, req *game.DelActivityConfigReq) (res *game.DelActivityConfigRes, err error) + GetAllGameActivity(ctx context.Context, req *game.GetAllGameActivityReq) (res *game.GetAllGameActivityRes, err error) +} + +type gameActivityImpl struct { +} + +var gameActivityService = gameActivityImpl{} + +func GameActivity() IGameActivity { + return &gameActivityService +} + +func (c *gameActivityImpl) GetGameActivity(ctx context.Context, req *game.GetActivityConfigsReq) (res *game.GetActivityConfigsRes, err error) { + g.Try(ctx, func(ctx context.Context) { + res = new(game.GetActivityConfigsRes) + model := dao.GameActivityTime.Ctx(ctx) + res.Total, err = model.Count() + liberr.ErrIsNil(ctx, err, "mysql err") + model = model.OrderAsc("config_id").Page(req.PageNum, req.PageSize) + if req.ServerId != 0 { + model = model.Where("server_id=?", req.ServerId) + } + err = model.Scan(&res.List) + }) + return +} + +func (c *gameActivityImpl) AddGameActivity(ctx context.Context, req *game.AddActivityConfigReq) (res *game.AddActivityConfigRes, err error) { + res = new(game.AddActivityConfigRes) + err = g.Try(ctx, func(ctx context.Context) { + server := []entity.GameActivityTime{} + model := dao.GameActivityTime.Ctx(ctx) + model.WherePri(req.Id).Scan(&server) + if len(server) > 0 { + data := g.Map{ + dao.GameActivityTime.Columns().Id: req.Id, + } + if req.CloseTime != "" { + data[dao.GameActivityTime.Columns().CloseTime] = req.CloseTime + } + if req.EndTime != "" { + data[dao.GameActivityTime.Columns().EndTime] = req.EndTime + } + if req.PreviewTime != "" { + data[dao.GameActivityTime.Columns().PreviewTime] = req.PreviewTime + } + if req.StartTime != "" { + data[dao.GameActivityTime.Columns().StartTime] = req.StartTime + } + if req.Remark != "" { + data[dao.GameActivityTime.Columns().Remark] = req.Remark + } + if req.ConfigId != 0 { + data[dao.GameActivityTime.Columns().ConfigId] = req.ConfigId + } + if req.ServerId != 0 { + data[dao.GameActivityTime.Columns().ServerId] = req.ServerId + } + _, err = model.WherePri(req.Id).Update(data) + } else { + _, err = model.Insert(do.GameActivityTime{ + ServerId: req.ServerId, + StartTime: gtime.NewFromStr(req.StartTime), + PreviewTime: gtime.NewFromStr(req.PreviewTime), + EndTime: gtime.NewFromStr(req.EndTime), + CloseTime: gtime.NewFromStr(req.CloseTime), + ConfigId: req.ConfigId, + Remark: req.Remark, + }) + } + }) + return +} + +func (c *gameActivityImpl) DelGameActivity(ctx context.Context, req *game.DelActivityConfigReq) (res *game.DelActivityConfigRes, err error) { + err = g.Try(ctx, func(ctx context.Context) { + if req.Id == 0 { + liberr.ErrIsNil(ctx, err, "错误的id") + } + _, e := dao.GameActivityTime.Ctx(ctx).Where("id=", req.Id).Delete() + if e != nil { + liberr.ErrIsNil(ctx, e, "删除失败") + } + }) + + return +} + +func (c *gameActivityImpl) GetAllGameActivity(ctx context.Context, req *game.GetAllGameActivityReq) (res *game.GetAllGameActivityRes, err error) { + g.Try(ctx, func(ctx context.Context) { + res = new(game.GetAllGameActivityRes) + + model := dao.GameActivityTime.Ctx(ctx) + serverConfigs := []entity.GameActivityTime{} + err = model.Where("server_id=?", req.ServerId).Scan(&serverConfigs) + if err != nil { + return + } + err = model.Where("server_id=?", 0).Scan(&res.List) + if err != nil { + return + } + configs := map[int]entity.GameActivityTime{} + for _, v := range serverConfigs { + configs[v.ConfigId] = v + } + for k, v := range res.List { + if configs[v.ConfigId].Id > 0 { + res.List[k] = configs[v.ConfigId] + } + } + }) + return +} diff --git a/internal/serviceGame/internal/game_activity.go b/internal/serviceGame/internal/game_activity.go new file mode 100644 index 0000000..b88b067 --- /dev/null +++ b/internal/serviceGame/internal/game_activity.go @@ -0,0 +1,31 @@ +package internal + +import ( + "context" + "tyj_admin/api/v1/game" + "tyj_admin/internal/dao" + "tyj_admin/internal/model/entity" +) + +func GetAllGameActivity(ctx context.Context, req *game.GetAllGameActivityReq) (res *game.GetAllGameActivityRes, err error) { + res = new(game.GetAllGameActivityRes) + + model := dao.GameActivityTime.Ctx(ctx) + defaultConfigs := []entity.GameActivityTime{} + _ = model.Where("server_id=?", 0).Scan(&defaultConfigs) + + serverConfigs := []entity.GameActivityTime{} + _ = model.Where("server_id=?", req.ServerId).Scan(&serverConfigs) + + configs := map[int]entity.GameActivityTime{} + for _, v := range serverConfigs { + configs[v.ConfigId] = v + } + for k, v := range defaultConfigs { + if configs[v.ConfigId].Id > 0 { + defaultConfigs[k] = configs[v.ConfigId] + } + } + + return +} diff --git a/internal/serviceGame/internal/online.go b/internal/serviceGame/internal/online.go index 890604d..bbf3582 100644 --- a/internal/serviceGame/internal/online.go +++ b/internal/serviceGame/internal/online.go @@ -11,6 +11,12 @@ import ( ) func IncrOnlineCount(ctx context.Context, server int) { + var loginUrl = []entity.GameLoginUrl{} + _ = dao.GameLoginUrl.Ctx(ctx).Where("id=?", server).Scan(&loginUrl) + if len(loginUrl) > 0 && loginUrl[0].Belong > 0 { + server = loginUrl[0].Belong + } + model := dao.GameOnlineCount.Ctx(ctx) model = model.Where("id=?", server) _, err := model.Update("online=online+1") @@ -26,6 +32,12 @@ func IncrOnlineCount(ctx context.Context, server int) { } func DecrOnlineCount(ctx context.Context, server int) { + var loginUrl = []entity.GameLoginUrl{} + _ = dao.GameLoginUrl.Ctx(ctx).Where("id=?", server).Scan(&loginUrl) + if len(loginUrl) > 0 && loginUrl[0].Belong > 0 { + server = loginUrl[0].Belong + } + model := dao.GameOnlineCount.Ctx(ctx) model = model.Where("id=?", server) _, err := model.Update("online=online-1")