Commit a2588efe953956280e5db5f86b495d19ab9ca86f

Authored by 王家文
1 parent 02370d5e
Exists in master

feat✨:排行榜功能 获取配置接口优化

configs/confbase/external.go
@@ -83,7 +83,6 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { @@ -83,7 +83,6 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool {
83 info := obj.ConfInfo(gameId) 83 info := obj.ConfInfo(gameId)
84 currentKey := info.CacheCurrent 84 currentKey := info.CacheCurrent
85 currentId := zredis.GetString(currentKey) 85 currentId := zredis.GetString(currentKey)
86 - confRaw := new(T2)  
87 if currentId != "" { 86 if currentId != "" {
88 has = GetConfig[T1, T2](gameId, currentId, obj) 87 has = GetConfig[T1, T2](gameId, currentId, obj)
89 if has { 88 if has {
@@ -92,15 +91,23 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { @@ -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 return has 112 return has
106 } 113 }
configs/confcardholder/get.go
@@ -8,7 +8,10 @@ import ( @@ -8,7 +8,10 @@ import (
8 func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { 8 func GetCurrent(gameId string) (conf *ActivityConfig, has bool) {
9 conf = new(ActivityConfig) 9 conf = new(ActivityConfig)
10 has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) 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 return 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,7 +11,11 @@ func GetCurrent(gameId string, topType int) (conf *ActivityConfig, has bool) {
11 conf = new(ActivityConfig) 11 conf = new(ActivityConfig)
12 conf.Typ = topType 12 conf.Typ = topType
13 has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) 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 return 19 return
16 } 20 }
17 21