feat:优化项目信息
This commit is contained in:
@ -28,11 +28,11 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
type SmsCallback func(mobile, code string) error
|
||||
type SmsCallback func(mobile, code string, function func() error) error
|
||||
|
||||
const (
|
||||
// SmsCaptchaEffectiveTime 短信验证码有效时间
|
||||
SmsCaptchaEffectiveTime int = 3600 * 3
|
||||
SmsCaptchaEffectiveTime int = 60 * 3
|
||||
)
|
||||
|
||||
func (this *CaptchaSms) validate() (bool, error) {
|
||||
@ -55,13 +55,12 @@ func (this *CaptchaImage) validate() (bool, error) {
|
||||
// Sms 短信
|
||||
func (this *Captcha) Sms(length int, mobile string, callback SmsCallback) error {
|
||||
code := utils.GetRandomCode(length)
|
||||
// 存储redis
|
||||
if err := cache.Cache.Set(mobile, code, SmsCaptchaEffectiveTime); err != nil {
|
||||
return err
|
||||
}
|
||||
// 发送短信
|
||||
//NewSms().Handle(mobile)
|
||||
return callback(mobile, code)
|
||||
return callback(mobile, code, func() error {
|
||||
// 存储redis
|
||||
return cache.Cache.Set(mobile, code, SmsCaptchaEffectiveTime)
|
||||
})
|
||||
}
|
||||
|
||||
// Image 图形
|
||||
|
Reference in New Issue
Block a user