he2802 преди 1 година
родител
ревизия
c783e40a72
променени са 1 файла, в които са добавени 25 реда и са изтрити 0 реда
  1. 25 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserLoginKeyServiceImpl.java

+ 25 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserLoginKeyServiceImpl.java

@@ -11,6 +11,7 @@ import com.github.pagehelper.Page;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.top.goods.domain.TopGoodsSpecAttributeRelation;
 import com.zhongzheng.modules.user.bo.UserLoginKeyAddBo;
 import com.zhongzheng.modules.user.bo.UserLoginKeyEditBo;
 import com.zhongzheng.modules.user.bo.UserLoginKeyQueryBo;
@@ -23,6 +24,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -45,8 +47,23 @@ public class UserLoginKeyServiceImpl extends ServiceImpl<UserLoginKeyMapper, Use
 
     @Override
     public Boolean queryByUserKey(String userKey) {
+        String redisKey = "loginKey:"+userKey;
+        Integer value = redisCache.getCacheObject(redisKey);
+        if(Validator.isNotEmpty(value)){
+            if(value==1){
+                return true;
+            }else{
+                return false;
+            }
+
+        }
         UserLoginKey loginKey = getOne(new LambdaQueryWrapper<UserLoginKey>()
                 .eq(UserLoginKey::getUserKey, userKey).last("limit 1"));
+        if(Validator.isNotEmpty(loginKey)){
+            redisCache.setCacheObject(redisKey,loginKey.getStatus(),600, TimeUnit.SECONDS);
+        }else{
+            redisCache.deleteObject(redisKey);
+        }
         if(Validator.isNotEmpty(loginKey)&&loginKey.getStatus()==0){
             return false;
         }
@@ -128,6 +145,14 @@ public class UserLoginKeyServiceImpl extends ServiceImpl<UserLoginKeyMapper, Use
         objectLambdaUpdateWrapper.ne(UserLoginKey::getUserKey, bo.getUserKey());
         objectLambdaUpdateWrapper.set(UserLoginKey::getStatus, 0);
         this.update(null, objectLambdaUpdateWrapper);
+        List<UserLoginKey> list = list(new LambdaQueryWrapper<UserLoginKey>()
+                .eq(UserLoginKey::getUserId,bo.getUserId()));
+        for(UserLoginKey item: list){
+            if(!item.getUserKey().equals(bo.getUserKey())){
+                String redisKey = "loginKey:"+item.getUserKey();
+                redisCache.setCacheObject(redisKey,0,60, TimeUnit.SECONDS);
+            }
+        }
         String key = "LockAppAction_"+"bank"+"-"+bo.getUserId();
         String key2 = "LockAppAction_"+"jxjy"+"-"+bo.getUserId();
         redisCache.deleteObject(key);