Parcourir la source

授权平台操作日志bug修复

王鑫刚 il y a 2 jours
Parent
commit
1671192e23

+ 6 - 3
src/main/java/cn/hanghui/outapi/platform/common/service/impl/LoginServiceImpl.java

@@ -85,7 +85,7 @@ public class LoginServiceImpl implements LoginService {
         Account tokenAccount = new Account();
         tokenAccount.setName(loginDto.getAccountName());
         tokenAccount.setPassword(loginDto.getPassword());
-        Map<String, Object> payload = BeanUtil.beanToMap(tokenAccount);
+   
         if(AccountTypeEnum.ADMIN.getCode().equals(account.getAccountType())){
             ClassUtil.throwBusinessException(StrUtil.isBlank(loginDto.getPhone()),"手机号不能为空");
             ClassUtil.throwBusinessException(StrUtil.isBlank(loginDto.getCode()),"验证码不能为空");
@@ -94,10 +94,12 @@ public class LoginServiceImpl implements LoginService {
             LoginUserRedisDto dto = redisUtil.get(key);
             ClassUtil.throwBusinessException(!dto.getCode().equals(loginDto.getCode()),"验证码不正确");
             account.setLoginUserDtoList(CollUtil.toList(new LoginUserDto(dto.getName(),dto.getPhone())));
+            tokenAccount.setName(loginDto.getAccountName()+dto.getPhone());
         }
-
+        Map<String, Object> payload = BeanUtil.beanToMap(tokenAccount);
+        
         String token = JWTUtil.createToken(payload, JwtConfig.SECRET_KEY.getBytes());
-        redisTemplate.opsForValue().set(JwtConfig.TOKEN_PREFIX + loginDto.getAccountName().toLowerCase(), token, JwtConfig.EXPIRE_TIME, TimeUnit.SECONDS);
+        redisTemplate.opsForValue().set(JwtConfig.TOKEN_PREFIX + tokenAccount.getName().toLowerCase(), token, JwtConfig.EXPIRE_TIME, TimeUnit.SECONDS);
         redisTemplate.opsForValue().set(JwtConfig.SESSION_PREFIX + token, JSON.toJSONString(account), JwtConfig.EXPIRE_TIME, TimeUnit.SECONDS);
         return token;
     }
@@ -118,6 +120,7 @@ public class LoginServiceImpl implements LoginService {
         for (LoginUserDto item : loginUserDtoList) {
             if (item.getPhone().equals(dto.getPhone())) {
                 loginUserDto = item;
+                break;
             }
         }
         ClassUtil.checkData(loginUserDto,"手机号不存在");