fix: issues
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package consts
|
||||
|
||||
// Format
|
||||
//
|
||||
// // swagger:enum CacheKey
|
||||
// // ENUM(
|
||||
// // VerifyCode = "code:__CHANNEL__:%s",
|
||||
// // )
|
||||
11
backend/pkg/oauth/contracts.go
Normal file
11
backend/pkg/oauth/contracts.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package oauth
|
||||
|
||||
import "time"
|
||||
|
||||
type OAuthInfo interface {
|
||||
GetOpenID() string
|
||||
GetUnionID() string
|
||||
GetAccessToken() string
|
||||
GetRefreshToken() string
|
||||
GetExpiredAt() time.Time
|
||||
}
|
||||
39
backend/pkg/oauth/wechat.go
Normal file
39
backend/pkg/oauth/wechat.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user