czh 2 лет назад
Родитель
Сommit
a988550699

+ 20 - 1
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteSystemService.java

@@ -6,6 +6,7 @@ import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @desc: 基础信息远程接口
@@ -42,7 +43,7 @@ public interface RemoteSystemService {
     List<SysDictGroupResDto> queryDictGroupByType(String type);
 
     /**
-     * @param  type 字典类型,value key
+     * @param type 字典类型,value key
      * @return SysDictGroupResDto
      * @desc: 根据字典类型和key查字典组
      * @author: czh
@@ -68,6 +69,15 @@ public interface RemoteSystemService {
      */
     List<EntCacheResDto> queryEntCacheByIds(List<Long> entIds);
 
+    /**
+     * @desc: 从缓存批量查企业信息
+     * @author: yzc
+     * @date: 2023-07-10 8:59
+     * @Param entIds
+     * @return: Map
+     */
+    Map<Long, List<EntCacheResDto>> queryEntCacheMapByIds(List<Long> entIds);
+
     /**
      * @param entName 企业名
      * @return EntCacheResDto
@@ -94,4 +104,13 @@ public interface RemoteSystemService {
      * @return: java.util.List<com.sckw.system.api.model.dto.res.UserCacheResDto>
      */
     List<UserCacheResDto> queryUserCacheByIds(List<Long> userIds);
+
+    /**
+     * @desc: 从缓存查用户信息
+     * @author: yzc
+     * @date: 2023-07-10 17:59
+     * @Param userIds: 用户id
+     * @return: Map
+     */
+    Map<Long, List<UserCacheResDto>> queryUserCacheMapByIds(List<Long> userIds);
 }

+ 19 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author czh
@@ -220,6 +221,15 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
         return list;
     }
 
+    @Override
+    public Map<Long, List<EntCacheResDto>> queryEntCacheMapByIds(List<Long> entIds) {
+        List<EntCacheResDto> entCacheResDtos = queryEntCacheByIds(entIds);
+        if (CollectionUtils.isEmpty(entCacheResDtos)) {
+            return null;
+        }
+        return entCacheResDtos.stream().collect(Collectors.groupingBy(EntCacheResDto::getId));
+    }
+
     @Override
     public UserCacheResDto queryUserCacheById(Long userId) {
         String key = Global.REDIS_USER_PREFIX + userId;
@@ -279,6 +289,15 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
         return list;
     }
 
+    @Override
+    public Map<Long, List<UserCacheResDto>> queryUserCacheMapByIds(List<Long> userIds) {
+        List<UserCacheResDto> userCacheResDtos = queryUserCacheByIds(userIds);
+        if (CollectionUtils.isEmpty(userCacheResDtos)) {
+            return null;
+        }
+        return userCacheResDtos.stream().collect(Collectors.groupingBy(UserCacheResDto::getId));
+    }
+
     /**
      * @param id 父id,需要遍历的list
      * @return SysDictGroupResDto