Commit 833152aba53a2d2feacaa1ced8ca702853a0ee35

Authored by 王家文
1 parent c7e0ab08
Exists in master and in 1 other branch dev-wjw

feat✨:排行榜功能

configs/confbase/external.go
@@ -8,12 +8,17 @@ import ( @@ -8,12 +8,17 @@ import (
8 "runtime/debug" 8 "runtime/debug"
9 ) 9 )
10 10
  11 +var CacheState = 1 // 0=关闭 1=打开
  12 +
11 func SaveCache[T IConfData](gameId string, obj T) { 13 func SaveCache[T IConfData](gameId string, obj T) {
12 info := obj.ConfInfo(gameId) 14 info := obj.ConfInfo(gameId)
13 _ = zredis.SetEx(info.CacheKey, zjson.Str(obj), info.CacheTime) 15 _ = zredis.SetEx(info.CacheKey, zjson.Str(obj), info.CacheTime)
14 } 16 }
15 17
16 func LoadCache[T IConfData](gameId string, obj T) (has bool) { 18 func LoadCache[T IConfData](gameId string, obj T) (has bool) {
  19 + if CacheState == 0 {
  20 + return false
  21 + }
17 has = true 22 has = true
18 info := obj.ConfInfo(gameId) 23 info := obj.ConfInfo(gameId)
19 text, err := zredis.Get(info.CacheKey) 24 text, err := zredis.Get(info.CacheKey)
controllers/admin.go 0 → 100644
@@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
  1 +package controllers
  2 +
  3 +import (
  4 + "apigame/configs/confbase"
  5 + "apigame/models"
  6 + "apigame/service/code-msg"
  7 +)
  8 +
  9 +// AdminController 绑定控制器
  10 +type AdminController struct {
  11 + BaseController
  12 +}
  13 +
  14 +// CacheSet 缓存
  15 +func (c *AdminController) CacheSet() {
  16 + req := new(models.ReqAdminCacheSet)
  17 + if !c.GetPostData(req) {
  18 + return
  19 + }
  20 +
  21 + confbase.CacheState = req.State
  22 + rsp := models.RspAdminCacheSet{State: confbase.CacheState}
  23 +
  24 + c.RetRspCodeData(code_msg.RECODE_OK, rsp)
  25 +}
models/admin.go 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +package models
  2 +
  3 +// ReqAdminCacheSet 请求
  4 +type ReqAdminCacheSet struct {
  5 + State int `form:"state" json:"state"` // 0=关闭 1=打开
  6 +}
  7 +
  8 +// RspAdminCacheSet 返回
  9 +type RspAdminCacheSet struct {
  10 + State int `form:"state" json:"state"` // 0=关闭 1=打开
  11 +}
routers/router.go
@@ -18,6 +18,10 @@ func init() { @@ -18,6 +18,10 @@ func init() {
18 // 获取随机名字和头像 18 // 获取随机名字和头像
19 beego.Router(prefix+"/common/getnameavatar", &controllers.CommonController{}, "post:GetNameAvatar") 19 beego.Router(prefix+"/common/getnameavatar", &controllers.CommonController{}, "post:GetNameAvatar")
20 20
  21 + // 调试
  22 + // 关闭缓存/打开缓存
  23 + beego.Router(prefix+"/admin/cacheset", &controllers.AdminController{}, "post:CacheSet")
  24 +
21 // 卡包卡牌活动 25 // 卡包卡牌活动
22 // 活动配置 26 // 活动配置
23 beego.Router(prefix+"/cardholder/getconfig", &controllers.CardHolderController{}, "post:GetConfig") 27 beego.Router(prefix+"/cardholder/getconfig", &controllers.CardHolderController{}, "post:GetConfig")
service/roomrank/logic.go
@@ -44,9 +44,9 @@ func TrySettle(gameId string, topType int, player *Player, config *confroomrank. @@ -44,9 +44,9 @@ func TrySettle(gameId string, topType int, player *Player, config *confroomrank.
44 if player.SettleActivityId == config.Id && player.SettleActivityTime == activityTime { 44 if player.SettleActivityId == config.Id && player.SettleActivityTime == activityTime {
45 return 45 return
46 } 46 }
47 - if player.ActivityId == config.Id && player.ActivityTime == activityTime {  
48 - return  
49 - } 47 + //if player.ActivityId == config.Id && player.ActivityTime == activityTime {
  48 + // return
  49 + //}
50 //if player.ActivityId == 0 { 50 //if player.ActivityId == 0 {
51 // return 51 // return
52 //} 52 //}