mp.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @description 微信公共平台的接口
  2. package gowechat
  3. import (
  4. "net/http"
  5. "github.com/yaotian/gowechat/mp/account"
  6. "github.com/yaotian/gowechat/mp/bridge"
  7. "github.com/yaotian/gowechat/mp/jssdk"
  8. "github.com/yaotian/gowechat/mp/material"
  9. "github.com/yaotian/gowechat/mp/menu"
  10. "github.com/yaotian/gowechat/mp/oauth"
  11. "github.com/yaotian/gowechat/mp/template"
  12. "github.com/yaotian/gowechat/mp/user"
  13. )
  14. //MpMgr mp mgr
  15. type MpMgr struct {
  16. Wechat
  17. }
  18. //GetAccessToken 获取access_token
  19. func (c *MpMgr) GetAccessToken() (string, error) {
  20. return c.Context.GetAccessToken()
  21. }
  22. // GetOauth oauth2网页授权
  23. func (c *MpMgr) GetOauth() *oauth.Oauth {
  24. return oauth.NewOauth(c.Context)
  25. }
  26. // GetMaterial 素材管理
  27. func (c *MpMgr) GetMaterial() *material.Material {
  28. return material.NewMaterial(c.Context)
  29. }
  30. // GetJs js-sdk配置
  31. func (c *MpMgr) GetJs() *jssdk.Js {
  32. return jssdk.NewJs(c.Context)
  33. }
  34. // GetMenu 菜单管理接口
  35. func (c *MpMgr) GetMenu() *menu.Menu {
  36. return menu.NewMenu(c.Context)
  37. }
  38. // GetUser 用户管理接口
  39. func (c *MpMgr) GetUser() *user.User {
  40. return user.NewUser(c.Context)
  41. }
  42. // GetTemplate 模板消息接口
  43. func (c *MpMgr) GetTemplate() *template.Template {
  44. return template.NewTemplate(c.Context)
  45. }
  46. // GetMsgHandler 消息管理
  47. func (c *MpMgr) GetMsgHandler(req *http.Request, writer http.ResponseWriter) *bridge.MsgHandler {
  48. c.Context.Request = req
  49. c.Context.Writer = writer
  50. return bridge.NewMsgHandler(c.Context)
  51. }
  52. // GetQrcode 带参数的二维码
  53. func (c *MpMgr) GetQrcode() *account.Qrcode {
  54. return account.NewQrcode(c.Context)
  55. }