|
|
@@ -1,16 +1,19 @@
|
|
|
package org.springblade.auth.verification;
|
|
|
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.auth.utils.ImgVerifyCode;
|
|
|
import org.springblade.common.cache.CacheNames;
|
|
|
+import org.springblade.common.enums.CommonEnum;
|
|
|
import org.springblade.common.enums.NumberEnum;
|
|
|
import org.springblade.common.utils.RedisUtils;
|
|
|
import org.springblade.common.utils.VerificationCodeUtil;
|
|
|
import org.springblade.core.sms.model.SmsResponse;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.resource.feign.ISmsClient;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -72,9 +75,15 @@ public class verificationController {
|
|
|
// String code = VerificationCodeUtil.getVerificationCode(NumberEnum.SIX.number);
|
|
|
String code = "123456";
|
|
|
System.out.println("验证码:" + code);
|
|
|
- // TODO: 需要短信发送
|
|
|
- String params = "TemplateParamSet:[\"" + code + "\"]";
|
|
|
- R<SmsResponse> responseR = smsClient.sendMessage("tencent-kbs", params, phone);
|
|
|
+ String parameter = String.format(CommonEnum.SMS_MSG_TEMPLATE.info, code, "3");
|
|
|
+ R<SmsResponse> responseR = smsClient.sendMessage("tencent-kbs", parameter, phone);
|
|
|
+ SmsResponse smsResponse = responseR.getData();
|
|
|
+ if (ObjectUtils.isEmpty(smsResponse)) {
|
|
|
+ return R.fail("短信发送失败,请稍后重试");
|
|
|
+ }
|
|
|
+ if (org.springframework.util.StringUtils.hasText(smsResponse.getMsg())) {
|
|
|
+ return R.fail("短信发送失败,请稍后重试");
|
|
|
+ }
|
|
|
redisUtils.set(CacheNames.APP_LOGIN_CODE_KEY + redisKey, code, NumberEnum.THREE_HUNDRED.number);
|
|
|
return R.success(code);
|
|
|
}
|