From a2588efe953956280e5db5f86b495d19ab9ca86f Mon Sep 17 00:00:00 2001 From: 王家文 Date: Tue, 21 May 2024 15:27:22 +0800 Subject: [PATCH] feat✨:排行榜功能 获取配置接口优化 --- configs/confbase/external.go | 27 +++++++++++++++++---------- configs/confcardholder/get.go | 5 ++++- configs/confroomrank/get.go | 6 +++++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/configs/confbase/external.go b/configs/confbase/external.go index e204da0..a3568db 100644 --- a/configs/confbase/external.go +++ b/configs/confbase/external.go @@ -83,7 +83,6 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { info := obj.ConfInfo(gameId) currentKey := info.CacheCurrent currentId := zredis.GetString(currentKey) - confRaw := new(T2) if currentId != "" { has = GetConfig[T1, T2](gameId, currentId, obj) if has { @@ -92,15 +91,23 @@ func GetCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { } } } - if !has { - has = FindDuringTime[T1, T2](obj, confRaw, gameId) - if has { - obj.Decode(gameId, confRaw) - SaveCache(gameId, obj) - has = true - currentId = obj.GetUid() - _ = zredis.Set(currentKey, currentId) - } + return has +} + +// FindCurrent 查找 当前配置 +func FindCurrent[T1 IConfData, T2 IConfRawData](gameId string, obj T1) bool { + has := false + info := obj.ConfInfo(gameId) + currentKey := info.CacheCurrent + currentId := zredis.GetString(currentKey) + confRaw := new(T2) + has = FindDuringTime[T1, T2](obj, confRaw, gameId) + if has { + obj.Decode(gameId, confRaw) + SaveCache(gameId, obj) + has = true + currentId = obj.GetUid() + _ = zredis.Set(currentKey, currentId) } return has } diff --git a/configs/confcardholder/get.go b/configs/confcardholder/get.go index 81023d1..cc7efdb 100644 --- a/configs/confcardholder/get.go +++ b/configs/confcardholder/get.go @@ -8,7 +8,10 @@ import ( func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { conf = new(ActivityConfig) has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) - + if !has { + conf = new(ActivityConfig) + has = confbase.FindCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) + } return } diff --git a/configs/confroomrank/get.go b/configs/confroomrank/get.go index acd89ca..2171a0c 100644 --- a/configs/confroomrank/get.go +++ b/configs/confroomrank/get.go @@ -11,7 +11,11 @@ func GetCurrent(gameId string, topType int) (conf *ActivityConfig, has bool) { conf = new(ActivityConfig) conf.Typ = topType has = confbase.GetCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) - + if !has { + conf = new(ActivityConfig) + conf.Typ = topType + has = confbase.FindCurrent[*ActivityConfig, ActivityConfigRaw](gameId, conf) + } return } -- libgit2 0.21.0