Merge branch 'sk' into develop

This commit is contained in:
sk 2024-12-04 16:48:02 +08:00
commit d82b029a06
5 changed files with 62 additions and 5 deletions

View File

@ -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
}

View File

@ -1,6 +1,6 @@
package errors
import "github.com/idealeak/goserver/core/logger"
import "mongo.games.com/goserver/core/logger"
var (
begins = []Code{ErrorBegin}

View File

@ -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) {

1
go.mod
View File

@ -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

2
go.sum
View File

@ -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=