Kaynağa Gözat

大屏用户token不过期

zhb.dong 1 yıl önce
ebeveyn
işleme
8f035129bc

+ 6 - 1
zd-common/common-core/src/main/java/com/zd/common/core/security/TokenServiceImpl.java

@@ -5,6 +5,7 @@ import com.zd.common.core.utils.*;
 import com.zd.model.constant.BaseConstants;
 import com.zd.model.constant.CacheConstants;
 import com.zd.model.entity.LoginModel;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
@@ -35,7 +36,11 @@ public class TokenServiceImpl implements TokenService {
     @Override
     public Map<String, Object> createToken(LoginModel login) {
         Map<String, Object> map = createCommonToken(login, EXPIRE_TIME);
-        redisTemplate.opsForValue().set(ACCESS_TOKEN + map.get("access_token"), login, EXPIRE_TIME, TimeUnit.SECONDS);
+        if(ObjectUtils.isNotEmpty(login) && !StringUtils.isEmpty(login.getUserType()) && login.getUserType().equals("99")){
+            redisTemplate.opsForValue().set(ACCESS_TOKEN + map.get("access_token"), login);
+        }else{
+            redisTemplate.opsForValue().set(ACCESS_TOKEN + map.get("access_token"), login, EXPIRE_TIME, TimeUnit.SECONDS);
+        }
         //redisService.setCacheObject(ACCESS_TOKEN + map.get("access_token"), loginUser, EXPIRE_TIME, TimeUnit.SECONDS);
         return map;
     }