wework_msg_log.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package day_new
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // 企业微信群消息拉取日志表
  7. type WeworkMsgLog struct {
  8. Id uint64 `orm:"column(id);pk;auto" description:"自增ID"`
  9. Seq uint64 `orm:"column(seq)" description:"本次请求获取消息记录开始的seq值。首次访问填写0"`
  10. Limit int `orm:"column(limit)" description:"一次调用限制的limit值,不能超过1000"`
  11. Total int `orm:"column(total)" description:"实际拉取到的消息数"`
  12. ReqResult int8 `orm:"column(req_result)" description:"请求结果:1成功,2失败"`
  13. CreateTime time.Time `orm:"column(create_time)" description:"创建时间"`
  14. ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
  15. }
  16. func (w *WeworkMsgLog) TableName() string {
  17. return "wework_msg_log"
  18. }
  19. // AddMsgReqLog 新增调用记录
  20. func AddMsgReqLog(item *WeworkMsgLog) (err error) {
  21. o := orm.NewOrm()
  22. _, err = o.Insert(item)
  23. return
  24. }
  25. // GetLasReqLog 获取最近一次成功调用记录
  26. func GetLasReqLog() (item *WeworkMsgLog, err error) {
  27. o := orm.NewOrm()
  28. sql := `SELECT * FROM wework_msg_log WHERE req_result = 1 order by id desc`
  29. err = o.Raw(sql).QueryRow(&item)
  30. return
  31. }