|
@@ -349,21 +349,9 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 登录加密
|
|
|
|
- *
|
|
|
|
- * @param vo
|
|
|
|
- * @return
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
|
- public String loginByEncryption(EncryptionLoginDTO vo) throws Exception {
|
|
|
|
- final String username = vo.getUsername();
|
|
|
|
- final String password = vo.getPassword();
|
|
|
|
- String machineCode = vo.getMachineCode();
|
|
|
|
- final String sign = vo.getSign();
|
|
|
|
- final String appKey = vo.getAppKey();
|
|
|
|
- long currentTimeMillis = vo.getCurrentTimeMillis() / 1000;
|
|
|
|
|
|
+ //校验登录时参数
|
|
|
|
+ public void checkRational(String machineCode, String sign, String appKey, long timeMillis) {
|
|
|
|
+ long currentTimeMillis = timeMillis / 1000;
|
|
long currentTimeSecond = System.currentTimeMillis() / 1000;
|
|
long currentTimeSecond = System.currentTimeMillis() / 1000;
|
|
final long second = currentTimeSecond - currentTimeMillis;
|
|
final long second = currentTimeSecond - currentTimeMillis;
|
|
if (second > 30) {
|
|
if (second > 30) {
|
|
@@ -377,6 +365,20 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
|
|
if (Boolean.TRUE.equals(StringUtils.isEmpty(machineCode))) {
|
|
if (Boolean.TRUE.equals(StringUtils.isEmpty(machineCode))) {
|
|
throw new XiaoShiException(ExceptionEnum.THE_MACHINE_CODE_IS_NULL);
|
|
throw new XiaoShiException(ExceptionEnum.THE_MACHINE_CODE_IS_NULL);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 登录加密
|
|
|
|
+ *
|
|
|
|
+ * @param vo
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
|
+ public String loginByEncryption(EncryptionLoginDTO vo) throws Exception {
|
|
|
|
+ final String username = vo.getUsername();
|
|
|
|
+ final String password = vo.getPassword();
|
|
|
|
+ String machineCode = vo.getMachineCode();
|
|
|
|
+ this.checkRational(machineCode, vo.getSign(), vo.getAppKey(), vo.getCurrentTimeMillis());
|
|
//用用户名查询人员信息
|
|
//用用户名查询人员信息
|
|
LambdaQueryWrapper<Personnel> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Personnel> queryWrapper = new LambdaQueryWrapper<>();
|
|
queryWrapper.eq(Personnel::getPersonnelPhone, username)
|
|
queryWrapper.eq(Personnel::getPersonnelPhone, username)
|
|
@@ -470,6 +472,20 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void checkedRational(String sign, String appKey, long TimeMillis) {
|
|
|
|
+ long currentTimeMillis = TimeMillis / 1000;
|
|
|
|
+ long currentTimeSecond = System.currentTimeMillis() / 1000;
|
|
|
|
+ final long second = currentTimeSecond - currentTimeMillis;
|
|
|
|
+ if (second > 30) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.THE_REQUEST_TIME_OVERTIME);
|
|
|
|
+ }
|
|
|
|
+ String appSecret = appKey + currentTimeMillis;
|
|
|
|
+ String md5Sign = SecureUtil.md5(appSecret);
|
|
|
|
+ if (Boolean.TRUE.equals(StringUtils.isEmpty(sign)) || !sign.equals(md5Sign)) {
|
|
|
|
+ throw new XiaoShiException(ExceptionEnum.THE_SIGN_IS_NOT_SAME);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 功能模块化代码加密
|
|
* 功能模块化代码加密
|
|
*
|
|
*
|
|
@@ -484,17 +500,7 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
|
|
if (Boolean.TRUE.equals(StringUtils.isEmpty(version))) {
|
|
if (Boolean.TRUE.equals(StringUtils.isEmpty(version))) {
|
|
version = "1.0.0.0";
|
|
version = "1.0.0.0";
|
|
}
|
|
}
|
|
- long currentTimeMillis = vo.getCurrentTimeMillis() / 1000;
|
|
|
|
- long currentTimeSecond = System.currentTimeMillis() / 1000;
|
|
|
|
- long second = currentTimeSecond - currentTimeMillis;
|
|
|
|
- if (second > 30) {
|
|
|
|
- return Response.error(ResponseEnum.THE_REQUEST_TIME_OVERTIME);
|
|
|
|
- }
|
|
|
|
- String appSecret = appKey + currentTimeMillis;
|
|
|
|
- String md5Sign = SecureUtil.md5(appSecret);
|
|
|
|
- if (Boolean.TRUE.equals(StringUtils.isEmpty(sign)) || !sign.equals(md5Sign)) {
|
|
|
|
- return Response.error(ResponseEnum.THE_SIGN_IS_NOT_SAME);
|
|
|
|
- }
|
|
|
|
|
|
+ this.checkedRational(sign, appKey, vo.getCurrentTimeMillis());
|
|
Integer userId = StpUtil.getLoginIdAsInt();
|
|
Integer userId = StpUtil.getLoginIdAsInt();
|
|
Personnel personnel = this.getById(userId);
|
|
Personnel personnel = this.getById(userId);
|
|
if (ObjectUtils.isEmpty(personnel)) {
|
|
if (ObjectUtils.isEmpty(personnel)) {
|
|
@@ -600,22 +606,7 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
public PhoneLoginVO loginByPhone(PhoneLoginDTO dto) throws Exception {
|
|
public PhoneLoginVO loginByPhone(PhoneLoginDTO dto) throws Exception {
|
|
String machineCode = dto.getMachineCode();
|
|
String machineCode = dto.getMachineCode();
|
|
- final String sign = dto.getSign();
|
|
|
|
- final String appKey = dto.getAppKey();
|
|
|
|
- long currentTimeMillis = dto.getCurrentTimeMillis() / 1000;
|
|
|
|
- long currentTimeSecond = System.currentTimeMillis() / 1000;
|
|
|
|
- final long second = currentTimeSecond - currentTimeMillis;
|
|
|
|
- if (second > 30) {
|
|
|
|
- throw new XiaoShiException(ExceptionEnum.THE_REQUEST_TIME_OVERTIME);
|
|
|
|
- }
|
|
|
|
- String appSecret = appKey + currentTimeMillis;
|
|
|
|
- String md5Sign = SecureUtil.md5(appSecret);
|
|
|
|
- if (Boolean.TRUE.equals(StringUtils.isEmpty(sign)) || !sign.equals(md5Sign)) {
|
|
|
|
- throw new XiaoShiException(ExceptionEnum.THE_SIGN_IS_NOT_SAME);
|
|
|
|
- }
|
|
|
|
- if (Boolean.TRUE.equals(StringUtils.isEmpty(machineCode))) {
|
|
|
|
- throw new XiaoShiException(ExceptionEnum.THE_MACHINE_CODE_IS_NULL);
|
|
|
|
- }
|
|
|
|
|
|
+ this.checkRational(machineCode, dto.getSign(), dto.getAppKey(), dto.getCurrentTimeMillis());
|
|
//获取缓存中验证码
|
|
//获取缓存中验证码
|
|
String code = redisUtil.get(LoginCacheKeyUtil.getLoginCaptcha(dto.getPhoneNum()));
|
|
String code = redisUtil.get(LoginCacheKeyUtil.getLoginCaptcha(dto.getPhoneNum()));
|
|
if (Boolean.TRUE.equals(StringUtils.isEmpty(code))) {
|
|
if (Boolean.TRUE.equals(StringUtils.isEmpty(code))) {
|