liuxiaolong
2020-08-18 d517b08bf4a526b696f6cdf391df64c7f6d43607
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
}