49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
|
|
package payment
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"context"
|
|||
|
|
"fmt"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// UserAuthModel 用户认证模型接口
|
|||
|
|
// 用于存储和管理用户的第三方认证信息(如微信OpenID)
|
|||
|
|
type UserAuthModel interface {
|
|||
|
|
FindOneByUserIdAuthType(ctx context.Context, userID string, authType string) (*UserAuth, error)
|
|||
|
|
UpsertUserAuth(ctx context.Context, userID, authType, authKey string) error
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UserAuth 用户认证信息
|
|||
|
|
type UserAuth struct {
|
|||
|
|
UserID string // 用户ID
|
|||
|
|
AuthType string // 认证类型
|
|||
|
|
AuthKey string // 认证密钥(如OpenID)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Platform 支付平台常量
|
|||
|
|
const (
|
|||
|
|
PlatformWxMini = "wx_mini" // 微信小程序
|
|||
|
|
PlatformWxH5 = "wx_h5" // 微信H5
|
|||
|
|
PlatformApp = "app" // APP
|
|||
|
|
PlatformWxNative = "wx_native" // 微信Native扫码
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// UserAuthType 用户认证类型常量
|
|||
|
|
const (
|
|||
|
|
UserAuthTypeWxMiniOpenID = "wx_mini_openid" // 微信小程序OpenID
|
|||
|
|
UserAuthTypeWxh5OpenID = "wx_h5_openid" // 微信H5 OpenID
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// DefaultUserAuthModel 默认实现(如果不需要实际数据库查询,可以返回错误)
|
|||
|
|
type DefaultUserAuthModel struct{}
|
|||
|
|
|
|||
|
|
// FindOneByUserIdAuthType 查找用户认证信息
|
|||
|
|
// 注意:这是一个占位实现,实际使用时需要注入真实的实现
|
|||
|
|
func (m *DefaultUserAuthModel) FindOneByUserIdAuthType(ctx context.Context, userID string, authType string) (*UserAuth, error) {
|
|||
|
|
return nil, fmt.Errorf("UserAuthModel未实现,请注入真实的实现")
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UpsertUserAuth 占位实现
|
|||
|
|
func (m *DefaultUserAuthModel) UpsertUserAuth(ctx context.Context, userID, authType, authKey string) error {
|
|||
|
|
return fmt.Errorf("UserAuthModel未实现,请注入真实的实现")
|
|||
|
|
}
|