This commit is contained in:
2024-04-22 21:12:21 +08:00
parent c27f9b76d6
commit 368093b799

View File

@@ -55,10 +55,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -406,13 +403,23 @@ public class UserService extends BaseService<UserEntity, UserRepository> {
strings = Stream.ofAll(strings).filter(StringUtils::isNotBlank).toJavaSet();
if (strings.isEmpty()) return Map.of();
List<String> names = new ArrayList<>();
List<String> names = this.repository.findNamesByIds(strings);
try {
Map<String, String> javaMap = Stream.ofAll(names).toMap(x -> x.split(",")[0], x -> x.split(",")[1]).toJavaMap();
names = this.repository.findNamesByIds(strings);
strings.forEach(x -> javaMap.putIfAbsent(x, null));
Map<String, String> javaMap =
Stream.ofAll(names)
.toMap(x -> x.split(",")[0], x -> x.split(",")[1])
.toJavaMap();
return javaMap;
strings.forEach(x -> javaMap.putIfAbsent(x, null));
return javaMap;
} catch (Exception e) {
log.error("获取用户名称失败 {}", StringUtils.join(names, " | "), e);
return Map.of();
}
}
}