From 180389ae7cbbeae5175a303a3811ebbf7650b132 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期一, 17 八月 2020 19:40:23 +0800 Subject: [PATCH] fix query log --- conf/app.conf | 1 + models/log.go | 4 ++-- controllers/car.go | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conf/app.conf b/conf/app.conf index adad79f..0a12de5 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -19,3 +19,4 @@ hikAppKey = 26577698 hikAppSecret = ZHhxujl06e0e5jsJLaiB pushLowerLimit = 5 +initPushLeft = 88 diff --git a/controllers/car.go b/controllers/car.go index f576697..0585eb8 100644 --- a/controllers/car.go +++ b/controllers/car.go @@ -25,7 +25,7 @@ //3.鏅氫笂10鐐瑰埌10鐐瑰崐锛屾瘡闂撮殧10鍒嗛挓锛岀粰鍋滆溅鍦哄唴鐨勮溅杈嗘帹閫佹秷鎭細璇峰敖蹇┒鍑哄仠杞﹀満 func ComputeSpaceLeftRealTime() { ticker := time.NewTicker(3 * time.Second) - prePushLeft := 0 + prePushLeft, _ := beego.AppConfig.Int("initPushLeft") //鍒濆鍓╀綑鏁伴噺锛屼笂绾垮悗涓嶈兘姣忔鍚姩閮芥帹閫佹秷鎭� sv := service.NewCarService() initCacheM := false lowerLimit,_ := beego.AppConfig.Int("pushLowerLimit") //[0,5] @@ -253,12 +253,16 @@ } var l models.Log total, logs := l.Find(curPage, pageSize, st, et) + var rl []models.Log + for _,le := range logs { + rl = append(rl, *le) + } resp := code.Code{ Success: true, Status: http.StatusOK, Data: map[string]interface{}{ "total": total, - "list": logs, + "list": rl, }, } c.Data["json"] = resp diff --git a/models/log.go b/models/log.go index da46e80..72170af 100644 --- a/models/log.go +++ b/models/log.go @@ -23,8 +23,8 @@ return o.Insert(l) } -func (l *Log) Find(curPage int, pageSize int, startTime string, endTime string) (int,[]Log) { - var list []Log +func (l *Log) Find(curPage int, pageSize int, startTime string, endTime string) (int,[]*Log) { + var list []*Log o := orm.NewOrm() var total int sql := "select count(*) from "+l.TableName()+" where createTime >='"+startTime+"' and createTime <= '"+endTime+"'" -- Gitblit v1.8.0