12345678910111213141516171819202122232425262728293031 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type MsgCode struct {
- MsgCodeId int `orm:"column(msg_code_id);pk"`
- OpenId string
- Mobile string
- Code string
- ExpiredIn int64
- Enabled int
- CreatedTime time.Time
- LastUpdatedTime time.Time
- }
- //添加用户session信息
- func AddMsgCode(item *MsgCode) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Insert(item)
- return
- }
- func GetMsgCode(mobile, code string) (item *MsgCode, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM msg_code WHERE mobile=? AND code=? AND FROM_UNIXTIME(expired_in)>=NOW() `
- err = o.Raw(sql, mobile, code).QueryRow(&item)
- return
- }
|