package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxShanghaiCompanyLog struct { Id int `orm:"column(id);pk"` Url string Body string Result string CreateTime time.Time } //添加日志记录 func AddCygxShanghaiCompanyLog(item *CygxShanghaiCompanyLog) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } type CygxShanghaiErrLog struct { Id int `orm:"column(id);pk"` ErrVal string ErrMsg string ErrType string CreateTime time.Time } //添加日志记录 func AddCygxShanghaiErrLog(item *CygxShanghaiErrLog) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } //列表 func GetCygxShanghaiCompanyLog() (items []*CygxShanghaiCompanyLog, err error) { o := orm.NewOrm() sql := ` SELECT * FROM cygx_shanghai_company_log WHERE create_time > date_format(now(),'%Y-%m-%d') AND url LIKE '%Customer/batchSyncFiccCustomer%'` _, err = o.Raw(sql).QueryRows(&items) return } //三十天之后的日志自行删除 func DeleteCygxShanghaiCompanyLog() (err error) { o := orm.NewOrm() sql := `DELETE FROM cygx_shanghai_company_log WHERE DATE_SUB(CURDATE(), INTERVAL 90 DAY) > date(create_time)` _, err = o.Raw(sql).Exec() return }