Merge branch 'feature-business-minigram' into dev

# Conflicts:
#	jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java
This commit is contained in:
Lemon
2026-01-07 10:49:06 +08:00
16 changed files with 359 additions and 48 deletions

View File

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* spring redis 工具类
@@ -603,4 +604,44 @@ public class RedisCache {
redisTemplate.opsForList().trim(redisKey, 0, 9);
}
/**
* 批量获取 Redis List 中每个 key 对应的最后一条数据
*
* @param keys Redis 键集合
* @param <T> 返回值类型
* @return Mapkey 为 Redis 键value 为对应 List 的最后一条数据
*/
public <T> Map<String, T> multiGetLastListValue(final List<String> keys) {
if (keys == null || keys.isEmpty()) {
return new HashMap<>();
}
Map<String, T> result = new HashMap<>();
for (String key : keys) {
if (StringUtils.isNotBlank(key)) {
// 使用 index -1 获取 List 的最后一个元素
T lastValue = (T) redisTemplate.opsForList().index(key, -1);
if (lastValue != null) {
result.put(key, lastValue);
}
}
}
return result;
}
/**
* 获取 Redis List 中指定 key 的最后一条数据
*
* @param key Redis 键
* @param <T> 返回值类型
* @return List 的最后一条数据,如果 key 不存在或 List 为空则返回 null
*/
public <T> T getLastListValue(final String key) {
if (StringUtils.isBlank(key)) {
return null;
}
// 使用 index -1 获取 List 的最后一个元素
return (T) redisTemplate.opsForList().index(key, -1);
}
}