wx_token_pc.go 652 B

123456789101112131415161718192021222324
  1. package models
  2. import "github.com/beego/beego/v2/client/orm"
  3. func PcGetWxToken() (item *WxToken, err error) {
  4. sql := `SELECT * FROM wx_pc_token `
  5. o := orm.NewOrm()
  6. err = o.Raw(sql).QueryRow(&item)
  7. return
  8. }
  9. func PcAddWxToken(token string, expiresIn int64) (err error) {
  10. sql := `INSERT INTO wx_pc_token(access_token, expires_in)VALUES(?,?) `
  11. o := orm.NewOrm()
  12. _, err = o.Raw(sql, token, expiresIn).Exec()
  13. return
  14. }
  15. func PcUpdateWxToken(token string, expiresIn int64, id int) (err error) {
  16. sql := `UPDATE wx_pc_token SET access_token=?, expires_in=? WHERE id=? `
  17. o := orm.NewOrm()
  18. _, err = o.Raw(sql, token, expiresIn, id).Exec()
  19. return
  20. }