fix: issues

This commit is contained in:
Rogee
2025-01-10 11:42:12 +08:00
parent 1c7b603769
commit 0d35aa15de
46 changed files with 1822 additions and 113 deletions

View File

@@ -0,0 +1,11 @@
package oauth
import "time"
type OAuthInfo interface {
GetOpenID() string
GetUnionID() string
GetAccessToken() string
GetRefreshToken() string
GetExpiredAt() time.Time
}

View File

@@ -0,0 +1,39 @@
package oauth
import "time"
var _ OAuthInfo = (*WechatOAuthInfo)(nil)
type WechatOAuthInfo struct {
Scope string `json:"scope,omitempty"`
OpenID string `json:"openid,omitempty"`
UnionID string `json:"unionid,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresIn int64 `json:"expires_in,omitempty"`
}
// GetAccessToken implements OAuthInfo.
func (w *WechatOAuthInfo) GetAccessToken() string {
return w.AccessToken
}
// GetExpiredAt implements OAuthInfo.
func (w *WechatOAuthInfo) GetExpiredAt() time.Time {
return time.Now().Add(time.Duration(w.ExpiresIn) * time.Second)
}
// GetOpenID implements OAuthInfo.
func (w *WechatOAuthInfo) GetOpenID() string {
return w.OpenID
}
// GetRefreshToken implements OAuthInfo.
func (w *WechatOAuthInfo) GetRefreshToken() string {
return w.RefreshToken
}
// GetUnionID implements OAuthInfo.
func (w *WechatOAuthInfo) GetUnionID() string {
return w.UnionID
}