|
|
@@ -1,6 +1,7 @@
|
|
|
package modules.user;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jdcloud.sdk.service.sms.model.BatchSendResponse;
|
|
|
import com.jfinal.aop.Before;
|
|
|
import com.jfinal.aop.Inject;
|
|
|
import com.jfinal.kit.HashKit;
|
|
|
@@ -12,6 +13,7 @@ import common.model.User;
|
|
|
import common.utils.http.MyController;
|
|
|
import common.utils.http.MyRet;
|
|
|
import common.utils.http.VerifyCode;
|
|
|
+import common.utils.jdcloud.SMS;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -41,7 +43,7 @@ public class UserController extends MyController {
|
|
|
JSONObject requestBodyJson = MyController.getJsonModelByRequestAndType(getRequest(), JSONObject.class);
|
|
|
|
|
|
// 从 JSON 对象中获取 mobile_number
|
|
|
-// String mobileNumber = requestBodyJson.getString("mobile_number");
|
|
|
+ String mobileNumber = requestBodyJson.getString("mobile_number");
|
|
|
|
|
|
// 2. 校验发送间隔
|
|
|
// 从 Session 中获取上次发送验证码的时间戳
|
|
|
@@ -65,15 +67,15 @@ public class UserController extends MyController {
|
|
|
setSessionAttr("last_send_verify_code_time", System.currentTimeMillis()); // 记录本次发送时间戳
|
|
|
|
|
|
// 5. 实际发送验证码(这里是模拟发送)
|
|
|
- // 这里替换为你的短信服务商接口调用逻辑
|
|
|
- // boolean isSentSuccessfully = smsService.send(mobile_number, verifyCode);
|
|
|
- boolean isSentSuccessfully = true; // 模拟发送成功
|
|
|
+ BatchSendResponse response = SMS.sendVerifyCodeByMobileNumber(mobileNumber, verifyCode);
|
|
|
+ String jsonResponse = JSONObject.toJSONString(response);
|
|
|
+ boolean isSentSuccessfully = response.getResult().getStatus();
|
|
|
|
|
|
if (isSentSuccessfully) {
|
|
|
- renderJson(MyRet.ok(String.format("验证码已发送,请注意查收 [测试验证码: %s]", verifyCode)));
|
|
|
+ renderJson(MyRet.ok("验证码已发送,请注意查收。").setData(jsonResponse));
|
|
|
} else {
|
|
|
// 短信服务商返回发送失败的情况处理
|
|
|
- renderJson(MyRet.fail("验证码发送失败,请稍后再试"));
|
|
|
+ renderJson(MyRet.fail("验证码发送失败,请稍后再试").setData(jsonResponse));
|
|
|
}
|
|
|
}
|
|
|
|