package notiser import ( "context" "91porn-server/app/appg" "91porn-server/app/service/emailser" "91porn-server/app/service/smsser" "91porn-server/common/constant" "91porn-server/common/stderr" ) const ( SMSMobileBind = 1 SMSCaptcha = 2 EmailCaptcha = 3 ) // SendCaptcha 发送验证码 func SendCaptcha(ctx context.Context, mobile, email string, typ int) stderr.Code { switch typ { case SMSCaptcha, SMSMobileBind: return smsser.SendSmsCode(ctx, mobile, typ) case EmailCaptcha: return SendEamil(ctx, email) default: return stderr.ErrNotSupportedCaptcha } } // VerifyCaptchaCode 校验验证码 func VerifyCaptchaCode(ctx context.Context, mobile, email, code string) stderr.Code { if appg.Conf.Base.Env != constant.ReleaseRunmod { // 测试环境为方便测试不校验验证码 return stderr.Success } if mobile != "" { return smsser.VerifySmsCode(mobile, code) } if email != "" { return emailser.VerifyCaptchaCode(ctx, email, code) } return stderr.ErrNotSupportedCaptcha }