123456789101112131415161718192021222324252627282930 |
- package wx_token
- import "github.com/beego/beego/v2/client/orm"
- type WxToken struct {
- AccessToken string
- ExpiresIn int64
- Id int `orm:"column(id);pk"`
- }
- func GetWxToken() (item *WxToken, err error) {
- sql := `SELECT * FROM wx_token `
- o := orm.NewOrm()
- err = o.Raw(sql).QueryRow(&item)
- return
- }
- func AddWxToken(token string, expiresIn int64) (err error) {
- sql := `INSERT INTO wx_token(access_token, expires_in)VALUES(?,?) `
- o := orm.NewOrm()
- _, err = o.Raw(sql, token, expiresIn).Exec()
- return
- }
- func UpdateWxToken(token string, expiresIn int64, id int) (err error) {
- sql := `UPDATE wx_token SET access_token=?, expires_in=? WHERE id=? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, token, expiresIn, id).Exec()
- return
- }
|