diff --git a/configs/confbase/external.go b/configs/confbase/external.go index 2362406..c225919 100644 --- a/configs/confbase/external.go +++ b/configs/confbase/external.go @@ -8,12 +8,17 @@ import ( "runtime/debug" ) +var CacheState = 1 // 0=关闭 1=打开 + func SaveCache[T IConfData](gameId string, obj T) { info := obj.ConfInfo(gameId) _ = zredis.SetEx(info.CacheKey, zjson.Str(obj), info.CacheTime) } func LoadCache[T IConfData](gameId string, obj T) (has bool) { + if CacheState == 0 { + return false + } has = true info := obj.ConfInfo(gameId) text, err := zredis.Get(info.CacheKey) diff --git a/controllers/admin.go b/controllers/admin.go new file mode 100644 index 0000000..40f575a --- /dev/null +++ b/controllers/admin.go @@ -0,0 +1,25 @@ +package controllers + +import ( + "apigame/configs/confbase" + "apigame/models" + "apigame/service/code-msg" +) + +// AdminController 绑定控制器 +type AdminController struct { + BaseController +} + +// CacheSet 缓存 +func (c *AdminController) CacheSet() { + req := new(models.ReqAdminCacheSet) + if !c.GetPostData(req) { + return + } + + confbase.CacheState = req.State + rsp := models.RspAdminCacheSet{State: confbase.CacheState} + + c.RetRspCodeData(code_msg.RECODE_OK, rsp) +} diff --git a/models/admin.go b/models/admin.go new file mode 100644 index 0000000..99f4c51 --- /dev/null +++ b/models/admin.go @@ -0,0 +1,11 @@ +package models + +// ReqAdminCacheSet 请求 +type ReqAdminCacheSet struct { + State int `form:"state" json:"state"` // 0=关闭 1=打开 +} + +// RspAdminCacheSet 返回 +type RspAdminCacheSet struct { + State int `form:"state" json:"state"` // 0=关闭 1=打开 +} diff --git a/routers/router.go b/routers/router.go index a4105d8..4effd91 100644 --- a/routers/router.go +++ b/routers/router.go @@ -18,6 +18,10 @@ func init() { // 获取随机名字和头像 beego.Router(prefix+"/common/getnameavatar", &controllers.CommonController{}, "post:GetNameAvatar") + // 调试 + // 关闭缓存/打开缓存 + beego.Router(prefix+"/admin/cacheset", &controllers.AdminController{}, "post:CacheSet") + // 卡包卡牌活动 // 活动配置 beego.Router(prefix+"/cardholder/getconfig", &controllers.CardHolderController{}, "post:GetConfig") diff --git a/service/roomrank/logic.go b/service/roomrank/logic.go index 668ee3e..ae66ecb 100644 --- a/service/roomrank/logic.go +++ b/service/roomrank/logic.go @@ -44,9 +44,9 @@ func TrySettle(gameId string, topType int, player *Player, config *confroomrank. if player.SettleActivityId == config.Id && player.SettleActivityTime == activityTime { return } - if player.ActivityId == config.Id && player.ActivityTime == activityTime { - return - } + //if player.ActivityId == config.Id && player.ActivityTime == activityTime { + // return + //} //if player.ActivityId == 0 { // return //} -- libgit2 0.21.0