feat:优化项目信息

This commit is contained in:
henry
2022-02-11 11:02:29 +08:00
parent 95f1401468
commit cbc0ad1a41
9 changed files with 132 additions and 24 deletions

View File

@ -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 图形