51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package app_server
|
|
|
|
type SendVerifyCode struct {
|
|
}
|
|
|
|
var SendVerifyCodeServer = new(SendVerifyCode)
|
|
|
|
// SendCode 获取手机短信验证码
|
|
func (s *SendVerifyCode) SendCode(mobile string) (string, error) {
|
|
//// 获取code
|
|
//smsCode := fmt.Sprintf("%06d", rand.Intn(1000000))
|
|
//
|
|
//// 发送短信
|
|
//response, err := api.SMSClient.Execute(globals.AliKey, globals.AliSecret, mobile, globals.SmsSignName, globals.SmsMobileVerifyTemplate, string(utils.MustMarshal(map[string]interface{}{
|
|
// "code": smsCode,
|
|
//})))
|
|
//
|
|
//if err != nil {
|
|
// return "", err
|
|
//}
|
|
//if response.Code != aliyunsmsclient.ResponseCodeOk {
|
|
// return "", fmt.Errorf("发送短信出错:%s", response.Message)
|
|
//}
|
|
//
|
|
//if err := putils.SetKey(response.BizId+"_"+mobile, smsCode, time.Minute*2); err != nil {
|
|
// globals.SugarLogger.Debugf("redis set key err key[%s] value[%s]:", mobile, smsCode)
|
|
// return "", err
|
|
//}
|
|
//
|
|
//return response.BizId, nil
|
|
return "111111", nil
|
|
}
|
|
|
|
// VerifySecret 检查验证码
|
|
func (s *SendVerifyCode) VerifySecret(mobile, bizId, code string) (bool, error) {
|
|
//result := putils.GetKey(bizId + "_" + mobile)
|
|
//fmt.Println(utils.IsNil(result))
|
|
//fmt.Println(result)
|
|
//if utils.IsNil(result) || result == "" || result == nil {
|
|
// return false, errors.New("验证码过期")
|
|
//}
|
|
//
|
|
//if result.(string) != code {
|
|
// return false, errors.New("验证码错误,重新确认")
|
|
//}
|
|
//
|
|
//defer putils.DelKey(bizId + "_" + mobile)
|
|
|
|
return true, nil
|
|
}
|