From 22dc0a767af4dd24bdb1d0402457cfab5359337c Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Wed, 4 Dec 2024 16:35:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=82=E6=95=B0=E4=B8=8D=E5=8C=BA=E5=88=86=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/config.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/common/config.go b/common/config.go index 3347b65..a15c366 100644 --- a/common/config.go +++ b/common/config.go @@ -2,6 +2,7 @@ package common import ( "encoding/json" + "strings" "mongo.games.com/goserver/core" ) @@ -53,6 +54,13 @@ func (this *CustomConfiguration) GetString(key string) string { return str } } + + if v, exist := (*this)[strings.ToLower(key)]; exist { + if str, ok := v.(string); ok { + return str + } + } + return "" } @@ -67,6 +75,18 @@ func (this *CustomConfiguration) GetStrings(key string) (strs []string) { return } } + + if v, exist := (*this)[strings.ToLower(key)]; exist { + if vals, ok := v.([]interface{}); ok { + for _, s := range vals { + if str, ok := s.(string); ok { + strs = append(strs, str) + } + } + return + } + } + return } @@ -86,6 +106,23 @@ func (this *CustomConfiguration) GetCustomCfgs(key string) (strs []*CustomConfig return } } + + if v, exist := (*this)[strings.ToLower(key)]; exist { + if vals, ok := v.([]interface{}); ok { + for _, s := range vals { + if data, ok := s.(map[string]interface{}); ok { + var pkg *CustomConfiguration + modelBuff, _ := json.Marshal(data) + err := json.Unmarshal(modelBuff, &pkg) + if err == nil { + strs = append(strs, pkg) + } + } + } + return + } + } + return } @@ -100,6 +137,18 @@ func (this *CustomConfiguration) GetInts(key string) (strs []int) { return } } + + if v, exist := (*this)[strings.ToLower(key)]; exist { + if vals, ok := v.([]interface{}); ok { + for _, s := range vals { + if str, ok := s.(float64); ok { + strs = append(strs, int(str)) + } + } + return + } + } + return } func (this *CustomConfiguration) GetInt(key string) int { @@ -108,6 +157,12 @@ func (this *CustomConfiguration) GetInt(key string) int { return int(val) } } + + if v, exist := (*this)[strings.ToLower(key)]; exist { + if val, ok := v.(float64); ok { + return int(val) + } + } return 0 } @@ -117,5 +172,10 @@ func (this *CustomConfiguration) GetBool(key string) bool { return val } } + if v, exist := (*this)[strings.ToLower(key)]; exist { + if val, ok := v.(bool); ok { + return val + } + } return false } From f78b1edfb3abc6e2af8bc06ddfffd6ae8838950e Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Wed, 4 Dec 2024 16:47:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=8C=85=E5=BC=95=E7=94=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/slotspkg/internal/generic/errors/init.go | 2 +- gamesrv/slotspkg/slots/handler.go | 2 +- go.mod | 1 - go.sum | 2 -- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gamesrv/slotspkg/internal/generic/errors/init.go b/gamesrv/slotspkg/internal/generic/errors/init.go index b34b914..b67b7ea 100644 --- a/gamesrv/slotspkg/internal/generic/errors/init.go +++ b/gamesrv/slotspkg/internal/generic/errors/init.go @@ -1,6 +1,6 @@ package errors -import "github.com/idealeak/goserver/core/logger" +import "mongo.games.com/goserver/core/logger" var ( begins = []Code{ErrorBegin} diff --git a/gamesrv/slotspkg/slots/handler.go b/gamesrv/slotspkg/slots/handler.go index 1615253..f4b8dd4 100644 --- a/gamesrv/slotspkg/slots/handler.go +++ b/gamesrv/slotspkg/slots/handler.go @@ -1,7 +1,6 @@ package slots import ( - "github.com/idealeak/goserver/core/logger" "mongo.games.com/game/gamesrv/base" "mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors" "mongo.games.com/game/gamesrv/slotspkg/internal/generic/global" @@ -10,6 +9,7 @@ import ( "mongo.games.com/game/gamesrv/slotspkg/internal/module/shared" "mongo.games.com/game/gamesrv/slotspkg/slots/machine" "mongo.games.com/game/gamesrv/slotspkg/slots/types/cli" + "mongo.games.com/goserver/core/logger" ) func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterResponse, error) { diff --git a/go.mod b/go.mod index 0eee4a1..24ed7df 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.1 github.com/google/go-querystring v1.1.0 github.com/howeyc/fsnotify v0.9.0 - github.com/idealeak/goserver v0.0.0-20201014040547-b8f686262078 github.com/jinzhu/now v1.1.5 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 github.com/mojocn/base64Captcha v1.3.6 diff --git a/go.sum b/go.sum index 00dcca3..ea89a77 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,6 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY= github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/idealeak/goserver v0.0.0-20201014040547-b8f686262078 h1:0Z5Im7EJiMKEiIQPPApdK0uOtyV5Ylo9wA3N9jWrfsU= -github.com/idealeak/goserver v0.0.0-20201014040547-b8f686262078/go.mod h1:ozCWDPw33jhq/GX7nsWS0cFCm5Jyag/Fy0LSQpKXT1I= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00 h1:QfdUfoZWIzBZ/FMtdUE/3wUwzsMU+PGTld17NDBld3k= github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00/go.mod h1:Q24O6QMGImDU3WY71P4YAxNb36NNn5qaznCfMUoXVfc=