|
@@ -5,7 +5,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.model.LoginBody;
|
|
import com.ruoyi.common.core.domain.model.LoginBody;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
import com.ruoyi.common.utils.SendSmsUtils;
|
|
import com.ruoyi.common.utils.SendSmsUtils;
|
|
-import com.ruoyi.system.service.ISysUserService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -27,8 +26,6 @@ import static com.ruoyi.common.constant.Constants.SMS_CODE;
|
|
public class SendSmsController {
|
|
public class SendSmsController {
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
- @Autowired
|
|
|
|
- private ISysUserService sysUserService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送登录短信接口
|
|
* 发送登录短信接口
|
|
@@ -39,10 +36,16 @@ public class SendSmsController {
|
|
@RepeatSubmit(interval = 1000, message = "请求过于频繁")
|
|
@RepeatSubmit(interval = 1000, message = "请求过于频繁")
|
|
public AjaxResult sendLoginSms(@RequestBody LoginBody user) {
|
|
public AjaxResult sendLoginSms(@RequestBody LoginBody user) {
|
|
String code = SendSmsUtils.getCode(6);
|
|
String code = SendSmsUtils.getCode(6);
|
|
- String phone = user.getUsername();
|
|
|
|
- SendSmsUtils.sendSms(phone, "SMS_219525380", "{\"code\":\"" + code + "\"}");
|
|
|
|
|
|
+ String phone = user.getPhoneNumber();
|
|
String key = SMS_CODE + phone;
|
|
String key = SMS_CODE + phone;
|
|
redisCache.setCacheObject(key, code, 5, TimeUnit.MINUTES);
|
|
redisCache.setCacheObject(key, code, 5, TimeUnit.MINUTES);
|
|
- return AjaxResult.success("发送成功");
|
|
|
|
|
|
+ //SendSmsUtils.sendSms(phone, "SMS_219525380", "{\"code\":\"" + code + "\"}");
|
|
|
|
+/* String codeResult = SendSmsUtils.sendSmsTp(phone, "383724", code );
|
|
|
|
+ if (SUCCESS_CODE.equals(codeResult)) {
|
|
|
|
+ String key = SMS_CODE + phone;
|
|
|
|
+ redisCache.setCacheObject(key, code, 5, TimeUnit.MINUTES);
|
|
|
|
+ return AjaxResult.success("发送成功");
|
|
|
|
+ }*/
|
|
|
|
+ return AjaxResult.error("发送失败"+code);
|
|
}
|
|
}
|
|
}
|
|
}
|