three_api_log.go 819 B

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