From cf8ba558ca2c2a3be8c199f380d2cea7b0b265c4 Mon Sep 17 00:00:00 2001 From: hoteas Date: Mon, 30 Oct 2017 08:23:42 +0000 Subject: [PATCH] --- application.go | 2 +- objtoobj.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/application.go b/application.go index b9496ac..30997be 100644 --- a/application.go +++ b/application.go @@ -39,7 +39,7 @@ func (this *Application) Run(router Router) { //this.Port = port this.Port = this.Config.GetString("port") - if this.connectDbFunc != nil && this.Db.DB.Ping() != nil { + if this.connectDbFunc != nil && (this.Db.DB==nil||this.Db.DB.Ping() != nil) { this.Db.SetConnect(this.connectDbFunc) } diff --git a/objtoobj.go b/objtoobj.go index ed9c598..2673e5a 100644 --- a/objtoobj.go +++ b/objtoobj.go @@ -240,7 +240,11 @@ func ObjToStr(obj interface{}) string { //字符串数组: a1,a2,a3转["a1","a2","a3"] func StrArrayToJsonStr(a string) string { + if len(a) != 0 { + if a[0] == ',' { + a = Substr(a, 1, len(a)) + } a = strings.Replace(a, ",", `","`, -1) a = `["` + a + `"]` } else { @@ -256,7 +260,7 @@ func JsonStrToStrArray(a string) string { a = Substr(a, 1, len(a)-2) } - return a + return "," + a } //字符串转int