|
@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.model.LoginBody;
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
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;
|
|
@@ -28,6 +29,8 @@ import static com.ruoyi.common.constant.CommonConstants.LOGIN_USER_SMS;
|
|
public class SendSmsController {
|
|
public class SendSmsController {
|
|
@Autowired
|
|
@Autowired
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送登录短信接口
|
|
* 发送登录短信接口
|
|
@@ -38,9 +41,14 @@ public class SendSmsController {
|
|
public AjaxResult sendLoginSms(@RequestBody LoginBody user) {
|
|
public AjaxResult sendLoginSms(@RequestBody LoginBody user) {
|
|
String code = SendSmsUtils.getCode(4);
|
|
String code = SendSmsUtils.getCode(4);
|
|
String username = user.getUsername();
|
|
String username = user.getUsername();
|
|
- redisCache.setCacheObject(LOGIN_USER_SMS + username, code,5, TimeUnit.MINUTES);
|
|
|
|
- String msg = SendSmsUtils.sendPassword(code, username);
|
|
|
|
- System.out.println(username+"登录短信发送回复:"+msg);
|
|
|
|
- return AjaxResult.success();
|
|
|
|
|
|
+ SysUser sysUser = sysUserService.selectUserByPhonenumber(username);
|
|
|
|
+ if (sysUser != null){
|
|
|
|
+ redisCache.setCacheObject(LOGIN_USER_SMS + username, code,5, TimeUnit.MINUTES);
|
|
|
|
+ String msg = SendSmsUtils.sendPassword(code, username);
|
|
|
|
+ System.out.println(username+"登录短信发送回复:"+msg);
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.error("当前手机号不存在");
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|