package models import ( "github.com/beego/beego/v2/client/orm" ) type WxToken struct { Id int `orm:"pk" description:"id"` // id AccessToken string `description:"微信token"` // 微信token ExpiresIn int64 `description:"过期时间"` // 过期时间 } func (w *WxToken) Insert() (err error) { o := orm.NewOrm() _, err = o.Insert(w) return } // Update 更新对应字段数据 func (w *WxToken) Update(cols []string) (err error) { o := orm.NewOrm() _, err = o.Update(w, cols...) return } // GetById 根据id获取accessToken信息 func GetWxTokenById() (info WxToken, err error) { o := orm.NewOrm() sql := `SELECT * FROM wx_token WHERE id = ?` err = o.Raw(sql, 0).QueryRow(&info) return }