config.go 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright (c) 2022 Yansen Zhang
  3. * wxcomponent is licensed under Mulan PSL v2.
  4. * You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. * You may obtain a copy of Mulan PSL v2 at:
  6. * http://license.coscl.org.cn/MulanPSL2
  7. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. * See the Mulan PSL v2 for more details.
  11. **/
  12. package config
  13. import (
  14. "time"
  15. "gitee.com/yansen_zh/wxcomponent/api/authorization"
  16. )
  17. type Config interface {
  18. // GetAppID 获取平台 APPID
  19. GetAppID() string
  20. // GetAppSecret 获取平台 APPSECRET
  21. GetAppSecret() string
  22. // GetAppSecret 获取平台消息校验Token
  23. GetMsgToken() string
  24. // GetToken 获取 Token
  25. GetAccessToken() string
  26. // RefreshToken 刷新 Token
  27. RefreshToken(token string, expire time.Time) error
  28. // GetTicket 获取票据
  29. GetVerifyTicket() string
  30. // RefreshTicket 刷新票据
  31. RefreshVerifyTicket(ticket string, expire time.Time) error
  32. // GetPushTicketState 是否开启票据推送服务
  33. GetPushTicketState() bool
  34. // RefreshPushTicketState 刷新票据推送服务状态
  35. RefreshPushTicketState(state bool)
  36. }
  37. var conf Config
  38. // AuthorizerConfig 公众号或小程序配置
  39. type AuthorizerConfig interface {
  40. // GetToken 获取 Token
  41. GetAccessToken(appID string) string
  42. // GetRefreshToken 获取 RefreshToken
  43. GetRefreshToken(appID string) string
  44. // RefreshToken 刷新 Token
  45. RefreshToken(appID, token, refreshToken string, expire time.Time) error
  46. // RefreshFuncInfo 刷新权限集列表
  47. RefreshFuncInfo(appID string, lst []authorization.FuncInfo)
  48. }