msg_code.go 726 B

123456789101112131415161718192021222324252627282930313233
  1. package models
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/orm"
  4. "time"
  5. )
  6. type MsgCode struct {
  7. MsgCodeId int `orm:"column(msg_code_id);pk"`
  8. OpenId string
  9. Mobile string
  10. Code string
  11. ExpiredIn int64
  12. Enabled int
  13. CreatedTime time.Time
  14. LastUpdatedTime time.Time
  15. }
  16. //添加用户session信息
  17. func AddMsgCode(item *MsgCode) (err error) {
  18. o := orm.NewOrm()
  19. o.Using("rddp")
  20. _, err = o.Insert(item)
  21. return
  22. }
  23. func GetMsgCode(mobile, code string) (item *MsgCode, err error) {
  24. o := orm.NewOrm()
  25. o.Using("rddp")
  26. sql := `SELECT * FROM msg_code WHERE mobile=? AND code=? AND FROM_UNIXTIME(expired_in)>=NOW() `
  27. err = o.Raw(sql, mobile, code).QueryRow(&item)
  28. return
  29. }