Commit 83ef3ff9b8ab20dfc8731f0cdd2961aebf0f053f

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

feat✨:游戏功能配置

Showing 2 changed files with 1 additions and 41 deletions   Show diff stats
configs/registry.go
... ... @@ -1,39 +0,0 @@
1   -package configs
2   -
3   -import (
4   - "apigame/configs/confroomrank"
5   - "apigame/service-common/svmysql"
6   - "apigame/service-common/svredis"
7   - "apigame/util/util-lx/lxalilog"
8   - "fmt"
9   -)
10   -
11   -// GetRoomRankConfig 获取 房间排行活动配置
12   -func GetRoomRankConfig(gameId string) (conf *confroomrank.ActivityConfig, has bool) {
13   - var err error
14   - conf = new(confroomrank.ActivityConfig)
15   - has = svredis.LoadData(gameId, conf)
16   - if has {
17   - fmt.Println("dwjw GetRoomRankConfig use cache")
18   - return
19   - }
20   - confRaw := new(confroomrank.ActivityConfigRaw)
21   - has, err = svmysql.First(confRaw, gameId)
22   - if err != nil {
23   - lxalilog.Errors(err, "configs.GetRoomRankConfig error", gameId)
24   - return
25   - }
26   - if !has {
27   -
28   - return
29   - }
30   -
31   - conf.Decode(gameId, confRaw)
32   -
33   - fmt.Println("dwjw GetRoomRankConfig save cache")
34   - fmt.Println("dwjw🐸", conf.Robot)
35   - fmt.Println("dwjw🐸", conf.Room)
36   - svredis.SaveData(gameId, conf)
37   -
38   - return
39   -}
service/roomrank/handle.go
1 1 package roomrank
2 2  
3 3 import (
4   - "apigame/configs"
5 4 "apigame/configs/confroomrank"
6 5 "apigame/models"
7 6 "apigame/service/code-msg"
... ... @@ -30,7 +29,7 @@ func HandleInfo(req *models.ReqRoomRankInfo) (code string, rsp models.RspRoomRan
30 29 playerUid := req.UID
31 30  
32 31 // 尝试更新配置
33   - config, hasConfig := configs.GetRoomRankConfig(gameId)
  32 + config, hasConfig := confroomrank.GetCurrent(gameId)
34 33 if !hasConfig {
35 34 code = code_msg.RECODE_MERGE_ROOMRANK_NOTOPEN_ERROR
36 35 return
... ...