From f64dd9f191dff341b4eb430d7bacc44a3db9a279 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期五, 04 三月 2022 10:12:45 +0800 Subject: [PATCH] fix nil --- models/log.go | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/models/log.go b/models/log.go index da46e80..cdd6958 100644 --- a/models/log.go +++ b/models/log.go @@ -23,14 +23,13 @@ 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+"'" - o.Raw(sql).QueryRow(&total) + o.Raw("select count(*) from "+l.TableName()+" where createTime >='"+startTime+"' and createTime <= '"+endTime+"'").QueryRow(&total) sn := (curPage-1)*pageSize - sql += " order by createTime desc limit "+strconv.Itoa(sn)+","+strconv.Itoa(pageSize)+"" + sql := "select * from "+l.TableName()+" where createTime >='"+startTime+"' and createTime <= '"+endTime+"' order by createTime desc limit "+strconv.Itoa(sn)+","+strconv.Itoa(pageSize)+"" o.Raw(sql).QueryRows(&list) return total, list } -- Gitblit v1.8.0