Commit a2588efe953956280e5db5f86b495d19ab9ca86f
1 parent
02370d5e
Exists in
master
feat✨:排行榜功能 获取配置接口优化
Showing
3 changed files
with
26 additions
and
12 deletions
Show diff stats
configs/confbase/external.go
| ... | ... | @@ -83,7 +83,6 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { |
| 83 | 83 | info := obj.ConfInfo(gameId) |
| 84 | 84 | currentKey := info.CacheCurrent |
| 85 | 85 | currentId := zredis.GetString(currentKey) |
| 86 | - confRaw := new(T2) | |
| 87 | 86 | if currentId != "" { |
| 88 | 87 | has = GetConfig[T1, T2](gameId, currentId, obj) |
| 89 | 88 | if has { |
| ... | ... | @@ -92,15 +91,23 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { |
| 92 | 91 | } |
| 93 | 92 | } |
| 94 | 93 | } |
| 95 | - if !has { | |
| 96 | - has = FindDuringTime[T1, T2](obj, confRaw, gameId) | |
| 97 | - if has { | |
| 98 | - obj.Decode(gameId, confRaw) | |
| 99 | - SaveCache(gameId, obj) | |
| 100 | - has = true | |
| 101 | - currentId = obj.GetUid() | |
| 102 | - _ = zredis.Set(currentKey, currentId) | |
| 103 | - } | |
| 94 | + return has | |
| 95 | +} | |
| 96 | + | |
| 97 | +// FindCurrent 查找 当前配置 | |
| 98 | +func FindCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { | |
| 99 | + has := false | |
| 100 | + info := obj.ConfInfo(gameId) | |
| 101 | + currentKey := info.CacheCurrent | |
| 102 | + currentId := zredis.GetString(currentKey) | |
| 103 | + confRaw := new(T2) | |
| 104 | + has = FindDuringTime[T1, T2](obj, confRaw, gameId) | |
| 105 | + if has { | |
| 106 | + obj.Decode(gameId, confRaw) | |
| 107 | + SaveCache(gameId, obj) | |
| 108 | + has = true | |
| 109 | + currentId = obj.GetUid() | |
| 110 | + _ = zredis.Set(currentKey, currentId) | |
| 104 | 111 | } |
| 105 | 112 | return has |
| 106 | 113 | } | ... | ... |
configs/confcardholder/get.go
| ... | ... | @@ -8,7 +8,10 @@ import ( |
| 8 | 8 | func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { |
| 9 | 9 | conf = new(ActivityConfig) |
| 10 | 10 | has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) |
| 11 | - | |
| 11 | + if !has { | |
| 12 | + conf = new(ActivityConfig) | |
| 13 | + has = confbase.FindCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) | |
| 14 | + } | |
| 12 | 15 | return |
| 13 | 16 | } |
| 14 | 17 | ... | ... |
configs/confroomrank/get.go
| ... | ... | @@ -11,7 +11,11 @@ func GetCurrent(gameId string, topType int) (conf *ActivityConfig, has bool) { |
| 11 | 11 | conf = new(ActivityConfig) |
| 12 | 12 | conf.Typ = topType |
| 13 | 13 | has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) |
| 14 | - | |
| 14 | + if !has { | |
| 15 | + conf = new(ActivityConfig) | |
| 16 | + conf.Typ = topType | |
| 17 | + has = confbase.FindCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) | |
| 18 | + } | |
| 15 | 19 | return |
| 16 | 20 | } |
| 17 | 21 | ... | ... |