sms_record.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package models
  2. import (
  3. "rdluck_tools/orm"
  4. "time"
  5. )
  6. type SmsRecord struct {
  7. Id int `orm:"column(id);pk"`
  8. Body string
  9. Mobile string
  10. SmsDate string
  11. IsSend int
  12. CreateTime time.Time
  13. ModifyTime time.Time
  14. SmsDateTime time.Time
  15. }
  16. //新增视频
  17. func AddSmsRecord(item *SmsRecord) (newId int64, err error) {
  18. o := orm.NewOrm()
  19. newId, err = o.Insert(item)
  20. return
  21. }
  22. func GetSmsRecordCount(mobile, smsDate string) (count int, err error) {
  23. o := orm.NewOrm()
  24. sql := `SELECT COUNT(1) AS count
  25. FROM sms_record AS a
  26. WHERE mobile=? AND sms_date=? `
  27. err = o.Raw(sql, mobile, smsDate).QueryRow(&count)
  28. return
  29. }
  30. func ModifySmsRecordIsSend(mobile, smsDate string) (err error) {
  31. o := orm.NewOrm()
  32. sql := `UPDATE sms_record SET is_send=1,modify_time=NOW() WHERE mobile=? AND sms_date=? `
  33. _, err = o.Raw(sql, mobile, smsDate).Exec()
  34. return
  35. }
  36. func GetSmsRecord() (items []*SmsRecord, err error) {
  37. o := orm.NewOrm()
  38. sql := `SELECT * FROM sms_record WHERE is_send=0 `
  39. _, err = o.Raw(sql).QueryRows(&items)
  40. return
  41. }