diff --git a/application.go b/application.go index 3c79203..f20289a 100644 --- a/application.go +++ b/application.go @@ -23,7 +23,6 @@ type Application struct { MakeCodeRouter map[string]*code.MakeCode MethodRouter Router - ContextBase Error Log *logrus.Logger WebConnectLog *logrus.Logger diff --git a/code/makecode.go b/code/makecode.go index 6c7fd13..05fd706 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -803,6 +803,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db * continue } + if v["list"] != false { if v.GetString("link") != "" && @@ -881,6 +882,38 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db * } + if v.GetString("type") == "text" { + reqValue := req.FormValue(v.GetString("name")) + if reqValue != "" { + data[table+"."+v.GetString("name")+"[~]"] = reqValue + } + + } + + if v.GetString("type") == "unixtime" { + //fmt.Println(req.Form["daterange"]) + if len(req.Form[v.GetString("name")]) == 1 { + daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange") + } else if len(req.Form[v.GetString("name")]) == 2 { + daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"]) + } + } + + if v.GetString("type") == "time" { + //fmt.Println(req.Form["daterange"]) + + if len(req.Form[v.GetString("name")]) == 1 { + t := time.Unix(ObjToCeilInt64(req.FormValue(v.GetString("name"))), 0).Format("2006-01-02 15:04:05") + + daterange[table+"."+v.GetString("name")+"[>]"] = t + + } else if len(req.Form[v.GetString("name")]) == 2 { + t1 := time.Unix(ObjToCeilInt64(req.Form[v.GetString("name")][0]), 0).Format("2006-01-02 15:04:05") + t2 := time.Unix(ObjToCeilInt64(req.Form[v.GetString("name")][1]), 0).Format("2006-01-02 15:04:05") + daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2} + } + } + if keywordStr != "" { if v.GetString("type") == "text" { keyword[table+"."+v.GetString("name")+"[~]"] = keywordStr @@ -954,7 +987,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db * if v.GetString("type") == "unixtime" { //fmt.Println(req.Form["daterange"]) if len(req.Form["daterange"]) == 1 { - daterange[table+"."+v.GetString("name")+"[<]"] = req.FormValue("daterange") + daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange") } else if len(req.Form["daterange"]) == 2 { daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"]) @@ -966,7 +999,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db * if len(req.Form["daterange"]) == 1 { t := time.Unix(ObjToCeilInt64(req.FormValue("daterange")), 0).Format("2006-01-02 15:04:05") - daterange[table+"."+v.GetString("name")+"[<]"] = t + daterange[table+"."+v.GetString("name")+"[>]"] = t } else if len(req.Form["daterange"]) == 2 { t1 := time.Unix(ObjToCeilInt64(req.Form["daterange"][0]), 0).Format("2006-01-02 15:04:05") diff --git a/context.go b/context.go index 00324a5..a134dca 100644 --- a/context.go +++ b/context.go @@ -1,7 +1,6 @@ package hotime import ( - . "code.hoteas.com/golang/hotime/cache" . "code.hoteas.com/golang/hotime/common" . "code.hoteas.com/golang/hotime/db" "encoding/json" @@ -19,7 +18,7 @@ type Context struct { Db *HoTimeDB RespData Map RespFunc func() - CacheIns + //CacheIns SessionIns DataSize int HandlerStr string //复写请求url diff --git a/db/hotimedb.go b/db/hotimedb.go index 8c4f955..80f7800 100644 --- a/db/hotimedb.go +++ b/db/hotimedb.go @@ -34,7 +34,7 @@ type HoTimeDB struct { } type HotimeDBBuilder struct { - *HoTimeDB + HoTimeDB *HoTimeDB table string selects []interface{} join Slice