|
@@ -16,6 +16,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -34,6 +35,12 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Log4j2
|
|
|
public class IndexController {
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * token过期时间,有效期一天
|
|
|
+ */
|
|
|
+ private static int tokenExpire = 1000*60*60*24;
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
@@ -81,7 +88,8 @@ public class IndexController {
|
|
|
tokenMap.put("role", roles);
|
|
|
|
|
|
|
|
|
- String token = JwtUtil2.createJWT(-1, tokenMap);
|
|
|
+// String token = JwtUtil2.createJWT(-1, tokenMap);
|
|
|
+ String token = JwtUtil2.createJWT(tokenExpire, tokenMap);
|
|
|
//
|
|
|
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
@@ -93,7 +101,7 @@ public class IndexController {
|
|
|
|
|
|
|
|
|
// 更新到 redis, 有效期24h, 旧token无效
|
|
|
- redisTemplate.opsForValue().set(userEntity.getUserName(), token, Long.parseLong("240000"), TimeUnit.HOURS);
|
|
|
+ redisTemplate.opsForValue().set(userEntity.getUserName(), token, Long.parseLong("23"), TimeUnit.HOURS);
|
|
|
|
|
|
// 更新登录次数
|
|
|
Integer loginCount = userEntity.getViewCount();
|