123456789101112131415161718192021222324252627282930 |
- package models
- import (
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- // MsgCode 验证码列表
- type MsgCode struct {
- MsgCodeId int64 `orm:"pk" description:"id"` // 短信验证码id
- OpenId string `description:"用户openId"` // 用户id
- Mobile string `description:"手机号/邮箱"` // 手机号/邮箱
- Code string `description:"验证码"` // 验证码
- ExpiredIn int64 `description:"过期时间"` // 过期时间
- CreateTime time.Time `description:"创建时间"` // 创建时间
- }
- func (m *MsgCode) Insert() (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(m)
- return
- }
- func GetMsgCode(mobile, code string) (item *MsgCode, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM msg_code WHERE mobile=? AND code=? AND FROM_UNIXTIME(expired_in)>=NOW() `
- err = o.Raw(sql, mobile, code).QueryRow(&item)
- return
- }
|