123456789101112131415161718192021222324252627282930313233343536 |
- 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
- }
- type MsgCodeResp struct {
- Mobile string `description:"手机号"`
- AreaNum string `description:"地区编码 国内默认为空"`
- }
- //添加用户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
- }
|