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 | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/models/log.go b/models/log.go index 2640e7f..cdd6958 100644 --- a/models/log.go +++ b/models/log.go @@ -1 +1,35 @@ package models + +import ( + "github.com/astaxie/beego/orm" + "strconv" +) + +//cid鍜屽埆鍚嶇粦瀹氳褰� +type Log struct { + Id string `orm:"pk;size(50);column(id)" json:"id"` + CreateTime string `orm:"column(createTime)" json:"createTime"` //鍒涘缓鏃堕棿 + Result bool `orm:"column(result)" json:"result"` //鎺ㄩ�佺粨鏋� + Phones string `orm:"size(8000);column(phones)" json:"phones"` //鎺ㄩ�佺洰鏍囨墜鏈哄彿 + Content string `orm:"column(content)" json:"content"` //鍓╀綑杞︿綅 +} + +func (l *Log) TableName() string { + return "log" +} + +func (l *Log) Insert() (int64,error) { + o := orm.NewOrm() + return o.Insert(l) +} + +func (l *Log) Find(curPage int, pageSize int, startTime string, endTime string) (int,[]*Log) { + var list []*Log + o := orm.NewOrm() + var total int + o.Raw("select count(*) from "+l.TableName()+" where createTime >='"+startTime+"' and createTime <= '"+endTime+"'").QueryRow(&total) + sn := (curPage-1)*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