From a831db0a4ea2341b930abc4aa4d83955780ee29f Mon Sep 17 00:00:00 2001 From: boyce Date: Wed, 27 Feb 2019 18:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96dbmodule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sysmodule/DBModule.go | 9 ++++++--- sysmodule/DBModule_test.go | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sysmodule/DBModule.go b/sysmodule/DBModule.go index 13139a1..5009de2 100644 --- a/sysmodule/DBModule.go +++ b/sysmodule/DBModule.go @@ -71,6 +71,7 @@ func (slf *DBResult) Close() { } } +/* // Next ... func (slf *DBResult) Next() bool { if slf.Err != nil { @@ -86,7 +87,7 @@ func (slf *DBResult) Scan(arg ...interface{}) error { } return slf.res.Scan(arg...) } - +*/ // SetSpecificTag ... func (slf *DBResult) SetSpecificTag(tag string) *DBResult { slf.tag = tag @@ -297,8 +298,10 @@ func (slf *SyncDBResult) Get(timeoutMs int) DBResult { func (slf *DBModule) Query(query string, args ...interface{}) DBResult { rows, err := slf.db.Query(query, args...) return DBResult{ - Err: err, - res: rows, + Err: err, + res: rows, + tag: "json", + blur: true, } } diff --git a/sysmodule/DBModule_test.go b/sysmodule/DBModule_test.go index 2603cb1..0032f94 100644 --- a/sysmodule/DBModule_test.go +++ b/sysmodule/DBModule_test.go @@ -25,14 +25,26 @@ func TestDBModule(t *testing.T) { Uuid string `json:"uuid,omitempty"` AAAA string `json:"xxx"` }{} - err := res.SetSpecificTag("json").SetBlurMode(true).UnMarshal(&out) + err := res.UnMarshal(&out) if err != nil { t.Error(err) } sres := db.SyncQuery("select * from tbl_fun_heelthrow where id >= 1") - res = sres.Get(1000) + res = sres.Get(2000) if res.Err != nil { t.Error(res.Err) } + + out2 := []struct { + Addtime int64 `json:"addtime"` + Tname string `json:"tname"` + Uuid string `json:"uuid,omitempty"` + AAAA string `json:"xxx"` + }{} + + err = res.UnMarshal(&out2) + if err != nil { + t.Error(err) + } }