common

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheKeySMSCode 短信验证码的缓存key
	CacheKeySMSCode string = "smscode:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AliyunInternationalProvider

type AliyunInternationalProvider struct {
	log.Log
	// contains filtered or unexported fields
}

func (*AliyunInternationalProvider) SendSMS

func (a *AliyunInternationalProvider) SendSMS(ctx context.Context, zone, phone string, code string) error

type AliyunProvider

type AliyunProvider struct {
	log.Log
	// contains filtered or unexported fields
}

func (*AliyunProvider) SendSMS

func (a *AliyunProvider) SendSMS(ctx context.Context, zone, phone string, code string) error

type CodeType

type CodeType int

CodeType 验证码类型

const (
	// CodeTypeRegister 注册
	CodeTypeRegister CodeType = iota
	// CodeTypePayPWD 支付密码
	CodeTypePayPWD
	// CodeTypeForgetLoginPWD 忘记登录密码
	CodeTypeForgetLoginPWD
	// CodeTypeCheckMobile 校验指定手机号是否正确
	CodeTypeCheckMobile
	// DestroyAccount 注销账号
	CodeTypeDestroyAccount
)

type ISMSProvider

type ISMSProvider interface {
	SendSMS(ctx context.Context, zone, phone string, code string) error
}

func NewAliyunInternationalProvider

func NewAliyunInternationalProvider(ctx *config.Context) ISMSProvider

NewAliyunInternationalProvider 创建短信服务

func NewAliyunProvider

func NewAliyunProvider(ctx *config.Context) ISMSProvider

NewAliyunProvider 创建短信服务

func NewUnismsProvider

func NewUnismsProvider(ctx *config.Context) ISMSProvider

NewUnismsProvider 创建短信服务

type ISMSService

type ISMSService interface {
	// 发送验证码
	SendVerifyCode(ctx context.Context, zone, phone string, codeType CodeType) error
	// 验证验证码(销毁缓存)
	Verify(ctx context.Context, zone, phone, code string, codeType CodeType) error
}

ISMSService ISMSService

type SMSService

type SMSService struct {
	log.Log
	// contains filtered or unexported fields
}

SMSService 短信服务

func NewSMSService

func NewSMSService(ctx *config.Context) *SMSService

NewSMSService 创建短信服务

func (*SMSService) SendVerifyCode

func (s *SMSService) SendVerifyCode(ctx context.Context, zone, phone string, codeType CodeType) error

SendVerifyCode 发送验证码

func (*SMSService) Verify

func (s *SMSService) Verify(ctx context.Context, zone, phone, code string, codeType CodeType) error

Verify 验证验证码

type UnismsProvider

type UnismsProvider struct {
	log.Log
	// contains filtered or unexported fields
}

func (*UnismsProvider) SendSMS

func (u *UnismsProvider) SendSMS(ctx context.Context, zone, phone string, code string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL