上传武器添加数据库报错问题,以及日志堆栈信息调整

This commit is contained in:
liwei1dao 2022-08-10 19:28:53 +08:00
parent ccbac50506
commit 18edbbad87
4 changed files with 43 additions and 4 deletions

View File

@ -102,7 +102,7 @@ func newOptions(config map[string]interface{}, opts ...Option) (options *Options
MaxBackups: 250, MaxBackups: 250,
Compress: false, Compress: false,
Encoder: TextEncoder, Encoder: TextEncoder,
CallerSkip: 0, CallerSkip: 3,
ReportCaller: ErrorLevel, ReportCaller: ErrorLevel,
IsDebug: true, IsDebug: true,
} }
@ -128,7 +128,7 @@ func newOptionsByOption(opts ...Option) (options *Options, err error) {
MaxBackups: 250, MaxBackups: 250,
Compress: false, Compress: false,
Encoder: TextEncoder, Encoder: TextEncoder,
CallerSkip: 0, CallerSkip: 3,
ReportCaller: ErrorLevel, ReportCaller: ErrorLevel,
IsDebug: true, IsDebug: true,
} }

View File

@ -0,0 +1,38 @@
package json_test
import (
"fmt"
"go_dreamfactory/lego/utils/codec/json"
"testing"
)
type TestData struct {
Name string
Age int
List []string
Map map[string]interface{}
}
//测试api_getlist
func Test_Json_Write(t *testing.T) {
ret, err := json.MarshalMap(&TestData{
Name: "liwei",
Age: 10,
List: []string{"123", "456", "789"},
Map: map[string]interface{}{
"aa": 123,
"b": "123123",
},
})
fmt.Printf("ret:%v err:%v", ret, err)
ret, err = json.MarshalMap(&TestData{
Name: "asdasd",
Age: 10,
List: []string{"12asd3", "45sdaa6", "asdasd"},
Map: map[string]interface{}{
"asd": 586,
"asdasd": "asd1231",
},
})
fmt.Printf("ret:%v err:%v", ret, err)
}

View File

@ -33,7 +33,7 @@ func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
err = mapstructure.Decode(settings, this) err = mapstructure.Decode(settings, this)
} }
if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 2)); this.Log == nil { if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 3)); this.Log == nil {
err = errors.New("log is nil") err = errors.New("log is nil")
} }
return return

View File

@ -190,7 +190,7 @@ func (this *DBModel) AddLists(uid string, data interface{}, opt ...DBOption) (er
} }
listskeys := make(map[string]string) listskeys := make(map[string]string)
keys := vof.MapKeys() keys := vof.MapKeys()
lists := make([]interface{}, len(keys)) lists := make([]interface{}, 0, len(keys))
pipe := this.Redis.RedisPipe(context.TODO()) pipe := this.Redis.RedisPipe(context.TODO())
for _, k := range keys { for _, k := range keys {
value := vof.MapIndex(k) value := vof.MapIndex(k)
@ -199,6 +199,7 @@ func (this *DBModel) AddLists(uid string, data interface{}, opt ...DBOption) (er
key := this.ukeylist(uid, keydata) key := this.ukeylist(uid, keydata)
pipe.HMSet(key, valuedata) pipe.HMSet(key, valuedata)
listskeys[keydata] = key listskeys[keydata] = key
lists = append(lists, valuedata)
} }
pipe.HMSetForMap(this.ukey(uid), listskeys) pipe.HMSetForMap(this.ukey(uid), listskeys)
if _, err = pipe.Exec(); err != nil { if _, err = pipe.Exec(); err != nil {