registry.go
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package configs
import (
"apigame/service-common/svmysql"
"apigame/service-common/svredis"
"apigame/util/util-lx/lxalilog"
"fmt"
)
// GetApiGameConfig 获取 api游戏配置
func GetApiGameConfig(gameId string) (conf *ApiGameConfig, err error) {
conf = new(ApiGameConfig)
has := svredis.LoadData(gameId, conf)
if has {
fmt.Println("dwjw GetApiGameConfig use cache")
return
}
has, err = svmysql.First(conf, gameId)
if err != nil {
lxalilog.Errors(err, "configs.GetApiGameConfig error", gameId)
return
}
if !has {
return
}
fmt.Println("dwjw GetApiGameConfig save cache")
svredis.SaveData(gameId, conf)
return
}
// GetCardActivityConfig 获取 卡牌活动配置
func GetCardActivityConfig(gameId string) (conf *CardActivityConfig, has bool) {
var err error
conf = new(CardActivityConfig)
has = svredis.LoadData(gameId, conf)
if has {
fmt.Println("dwjw GetCardActivityConfig use cache")
return
}
confRaw := new(CardActivityConfigRaw)
has, err = svmysql.First(confRaw, gameId)
if err != nil {
lxalilog.Errors(err, "configs.GetCardActivityConfig error", gameId)
return
}
if !has {
return
}
conf.Decode(gameId, confRaw)
fmt.Println("dwjw GetCardActivityConfig save cache")
svredis.SaveData(gameId, conf)
return
}
// GetRoomRankConfig 获取 房间排行活动配置
func GetRoomRankConfig(gameId string) (conf *RoomRankConfig, has bool) {
var err error
conf = new(RoomRankConfig)
has = svredis.LoadData(gameId, conf)
if has {
fmt.Println("dwjw GetRoomRankConfig use cache")
return
}
confRaw := new(RoomRankConfigRaw)
has, err = svmysql.First(confRaw, gameId)
if err != nil {
lxalilog.Errors(err, "configs.GetRoomRankConfig error", gameId)
return
}
if !has {
return
}
conf.Decode(gameId, confRaw)
fmt.Println("dwjw GetRoomRankConfig save cache")
fmt.Println("dwjw🐸", conf.Robot)
svredis.SaveData(gameId, conf)
return
}