Browse Source

activity, loginUrl新增belong, 在线修改新增belong服务器, 广告允许按钮

master
linquan 1 day ago
parent
commit
7449f77bb4
  1. 48
      api/v1/game/game_activity.go
  2. 33
      internal/controller/game_activity.go
  3. 0
      internal/controller/game_bazaar.go
  4. 0
      internal/controller/game_version.go
  5. 27
      internal/dao/csj_advertisement.go
  6. 27
      internal/dao/game_activity_time.go
  7. 79
      internal/dao/internal/csj_advertisement.go
  8. 87
      internal/dao/internal/game_activity_time.go
  9. 2
      internal/dao/internal/game_login_url.go
  10. 18
      internal/model/do/csj_advertisement.go
  11. 23
      internal/model/do/game_activity_time.go
  12. 2
      internal/model/do/game_login_url.go
  13. 13
      internal/model/entity/csj_advertisement.go
  14. 21
      internal/model/entity/game_activity_time.go
  15. 1
      internal/router/router.go
  16. 2
      internal/serviceGame/ccd.go
  17. 131
      internal/serviceGame/game_activity.go
  18. 31
      internal/serviceGame/internal/game_activity.go
  19. 12
      internal/serviceGame/internal/online.go

48
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 {
}

33
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
}

0
internal/controller/game_Bazaar.go → internal/controller/game_bazaar.go

0
internal/controller/game_Version.go → internal/controller/game_version.go

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

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

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

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

2
internal/dao/internal/game_login_url.go

@ -41,7 +41,7 @@ type GameLoginUrlColumns struct {
Remark string // 备注名称 Remark string // 备注名称
IsNew string // IsNew string //
Sort string // 后台排序 Sort string // 后台排序
Belong string // 附服务器 Belong string // 附服务器
} }
// gameLoginUrlColumns holds the columns for table game_login_url. // gameLoginUrlColumns holds the columns for table game_login_url.

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

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

2
internal/model/do/game_login_url.go

@ -33,5 +33,5 @@ type GameLoginUrl struct {
Remark interface{} // 备注名称 Remark interface{} // 备注名称
IsNew interface{} // IsNew interface{} //
Sort interface{} // 后台排序 Sort interface{} // 后台排序
Belong interface{} // 附服务器 Belong interface{} // 附服务器
} }

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

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

1
internal/router/router.go

@ -174,6 +174,7 @@ func GameBindController(group *ghttp.RouterGroup) {
controller.GameBug, controller.GameBug,
controller.GameChannel, controller.GameChannel,
controller.GameBattlePass, controller.GameBattlePass,
controller.GameActivity,
) )
}) })
} }

2
internal/serviceGame/ccd.go

@ -129,7 +129,7 @@ func (c *gameCCDImpl) GetGameCCD(ctx context.Context, req *game.GetGameCCDReq) (
} }
res.EnableAccountLogin = 0 res.EnableAccountLogin = 0
res.EnableHotfix = 1 res.EnableHotfix = 1
res.EnableAds = 0 res.EnableAds = 1
err = g.Try(ctx, func(ctx context.Context) { err = g.Try(ctx, func(ctx context.Context) {
if internal.GetEnableHotfix(ctx, req.ChannelType+req.Version) != "" { if internal.GetEnableHotfix(ctx, req.ChannelType+req.Version) != "" {
data, _ := strconv.Atoi(internal.GetEnableHotfix(ctx, req.ChannelType+req.Version)) data, _ := strconv.Atoi(internal.GetEnableHotfix(ctx, req.ChannelType+req.Version))

131
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
}

31
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
}

12
internal/serviceGame/internal/online.go

@ -11,6 +11,12 @@ import (
) )
func IncrOnlineCount(ctx context.Context, server int) { 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 := dao.GameOnlineCount.Ctx(ctx)
model = model.Where("id=?", server) model = model.Where("id=?", server)
_, err := model.Update("online=online+1") _, err := model.Update("online=online+1")
@ -26,6 +32,12 @@ func IncrOnlineCount(ctx context.Context, server int) {
} }
func DecrOnlineCount(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 := dao.GameOnlineCount.Ctx(ctx)
model = model.Where("id=?", server) model = model.Where("id=?", server)
_, err := model.Update("online=online-1") _, err := model.Update("online=online-1")

Loading…
Cancel
Save