第五修改

master
31353 2024-01-08 11:25:15 +08:00
parent afe4128893
commit 0856e6a335
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.bwie.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.common.utils.UuidUtils;
import com.bwie.common.constants.JwtConstants;
import com.bwie.common.constants.TokenConstants;
@ -130,7 +131,11 @@ public class AuthServicelmpl implements AuthService{
@Override
public Result info() {
return null;
String token = request.getHeader(TokenConstants.TOKEN);
String userKey = JwtUtils.getUserKey(token);
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
User user = JSON.parseObject(s, User.class);
return Result.success(user);
}
/**
@ -141,7 +146,7 @@ public class AuthServicelmpl implements AuthService{
String userKey = UuidUtils.generateUuid().replaceAll("-", "");
map.put(JwtConstants.USER_KEY,userKey);
String token = JwtUtils.createToken(map);
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey,token,15, TimeUnit.MINUTES);
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSON.toJSONString(user),15, TimeUnit.MINUTES);
return new JwtRequest(token);
}
}