|
@@ -8,7 +8,6 @@ import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
|
import com.rongwei.rwadmincommon.system.domain.UserLoginVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
-import com.rongwei.rwcommon.utils.DateUtils;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -23,8 +22,6 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Random;
|
|
|
|
|
|
-import static com.rongwei.bscommon.system.utils.QHSEConstant.ERROR_LOWER_CASE;
|
|
|
-
|
|
|
/**
|
|
|
* QHSELoginServiceImpl class
|
|
|
*
|
|
@@ -62,14 +59,16 @@ public class QHSELoginServiceImpl implements QHSELoginService {
|
|
|
String username = userLogin.getUsername();
|
|
|
// 错误次数
|
|
|
int errorNum = 0;
|
|
|
- if (redisService.hasKey("smscode-error-" + username)) {
|
|
|
- errorNum = Integer.parseInt(redisService.getRedisCatchObj("smscode-error-" + username).toString());
|
|
|
+ String smsErrorKey = "smscode-error-" + username;
|
|
|
+ if (redisService.hasKey(smsErrorKey)) {
|
|
|
+ errorNum = Integer.parseInt(redisService.getRedisCatchObj(smsErrorKey).toString());
|
|
|
}
|
|
|
if (errorNum > 10) {
|
|
|
log.error("用户:{},密码错误次数为:{}", username, errorNum + 1);
|
|
|
- throw new RuntimeException("密码错误次数已超过限制");
|
|
|
+ long expireTime = redisService.getExpireTime(smsErrorKey);
|
|
|
+ throw new RuntimeException("密码错误次数已超过限制!请" + expireTime + "秒后再试");
|
|
|
}
|
|
|
- String smsErrorKey = "smscode-error-" + username;
|
|
|
+
|
|
|
List<SysUserDo> sysUserDos = qhseUserService.list(new LambdaQueryWrapper<SysUserDo>()
|
|
|
.eq(BaseDo::getDeleted, "0").eq(SysUserDo::getAccount, username));
|
|
|
if (sysUserDos.isEmpty()) {
|
|
@@ -98,7 +97,8 @@ public class QHSELoginServiceImpl implements QHSELoginService {
|
|
|
|
|
|
if (errorNum >= 10) {
|
|
|
log.error("用户:{},密码错误次数为:{}", username, errorNum);
|
|
|
- throw new RuntimeException("密码错误次数已超过限制");
|
|
|
+ long expireTime = redisService.getExpireTime(smsErrorKey);
|
|
|
+ throw new RuntimeException("密码错误次数已超过限制!请" + expireTime + "秒后再试");
|
|
|
}
|
|
|
throw new RuntimeException("密码错误");
|
|
|
}
|
|
@@ -114,7 +114,7 @@ public class QHSELoginServiceImpl implements QHSELoginService {
|
|
|
Map<String, Object> templateParamMap = new HashMap<>();
|
|
|
templateParamMap.put("code", smsCode);
|
|
|
|
|
|
- aliyunSmsService.sendSms(smsCodeConfig.getTempId(),templateParamMap, mobile);
|
|
|
+ aliyunSmsService.sendSms(smsCodeConfig.getTempId(), templateParamMap, mobile);
|
|
|
} catch (Exception e) {
|
|
|
log.error("验证码发送失败原因为");
|
|
|
throw new RuntimeException(e.getMessage());
|
|
@@ -126,7 +126,7 @@ public class QHSELoginServiceImpl implements QHSELoginService {
|
|
|
}
|
|
|
|
|
|
public int generateSms() {
|
|
|
- return 100000 + new Random().nextInt(900000);
|
|
|
+ return 100000 + new Random().nextInt(900000);
|
|
|
}
|
|
|
|
|
|
|