shanghai_company_log.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxShanghaiCompanyLog struct {
  7. Id int `orm:"column(id);pk"`
  8. Url string
  9. Body string
  10. Result string
  11. CreateTime time.Time
  12. }
  13. //添加日志记录
  14. func AddCygxShanghaiCompanyLog(item *CygxShanghaiCompanyLog) (lastId int64, err error) {
  15. o := orm.NewOrm()
  16. lastId, err = o.Insert(item)
  17. return
  18. }
  19. type CygxShanghaiErrLog struct {
  20. Id int `orm:"column(id);pk"`
  21. ErrVal string
  22. ErrMsg string
  23. ErrType string
  24. CreateTime time.Time
  25. }
  26. //添加日志记录
  27. func AddCygxShanghaiErrLog(item *CygxShanghaiErrLog) (lastId int64, err error) {
  28. o := orm.NewOrm()
  29. lastId, err = o.Insert(item)
  30. return
  31. }
  32. //列表
  33. func GetCygxShanghaiCompanyLog() (items []*CygxShanghaiCompanyLog, err error) {
  34. o := orm.NewOrm()
  35. sql := ` SELECT * FROM cygx_shanghai_company_log WHERE create_time > date_format(now(),'%Y-%m-%d') AND url LIKE '%Customer/batchSyncFiccCustomer%'`
  36. _, err = o.Raw(sql).QueryRows(&items)
  37. return
  38. }
  39. //三十天之后的日志自行删除
  40. func DeleteCygxShanghaiCompanyLog() (err error) {
  41. o := orm.NewOrm()
  42. sql := `DELETE FROM cygx_shanghai_company_log WHERE DATE_SUB(CURDATE(), INTERVAL 90 DAY) > date(create_time)`
  43. _, err = o.Raw(sql).Exec()
  44. return
  45. }