27 lines
591 B
Go
27 lines
591 B
Go
package captcha
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
ErrCodeSendTooMany = errors.New("发送验证码太频繁")
|
|
ErrCodeVerifyFail = errors.New("验证码错误")
|
|
)
|
|
|
|
// Service 发送和验证验证码
|
|
type Service interface {
|
|
SendCode(ctx context.Context, phone string) error
|
|
VerifyCode(ctx context.Context, phone, code string) error
|
|
Close() error
|
|
}
|
|
|
|
type Store interface {
|
|
Set(ctx context.Context, key string, value string, timeout time.Duration) error
|
|
Get(ctx context.Context, key string) (string, error)
|
|
Delete(ctx context.Context, key string) error
|
|
Close() error
|
|
}
|