package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxThreeApiLog struct { Id int `orm:"column(id);pk"` Url string `description:"链接"` Body string `description:"请求参数"` Result string `description:"返回参数"` CreateTime time.Time `description:"活动模板,带P标签"` Source int `description:"来源1,易董"` } //添加日志记录 func AddCygxThreeApiLog(item *CygxThreeApiLog) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } //三十天之后的日志自行删除 func DeleteCygxThreeApiLog() (err error) { o := orm.NewOrm() sql := `DELETE FROM cygx_three_api_log WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) > date(create_time)` _, err = o.Raw(sql).Exec() return }