| | |
| | | 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 |
| | | sql := "select count(*) from "+l.TableName()+" where createTime >='"+startTime+"' and createTime <= '"+endTime+"'" |
| | | o.Raw(sql).QueryRow(&total) |
| | | sn := (curPage-1)*pageSize |
| | | sql += " order by createTime desc limit "+strconv.Itoa(sn)+","+strconv.Itoa(pageSize)+"" |
| | | o.Raw(sql).QueryRows(&list) |
| | | return total, list |
| | | } |