opt:6.15上线装箱区代码修改

This commit is contained in:
2024-06-17 11:01:36 +08:00
parent 78fb4e7a5f
commit 12e72ae6fd
31 changed files with 427 additions and 338 deletions

View File

@@ -15,6 +15,8 @@
*/
package org.nl.modules.common.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
@@ -42,6 +44,11 @@ public class RedisUtils {
@Value("${jwt.online-key}")
private String onlineKey;
private final ObjectMapper objectMapper = new ObjectMapper();
public RedisUtils(RedisTemplate<Object, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@@ -708,4 +715,25 @@ public class RedisUtils {
log.debug("缓存删除数量:" + count + "");
log.debug("--------------------------------------------");
}
public void pushToList(String key, Object value) {
try {
String valueJson = objectMapper.writeValueAsString(value);
redisTemplate.opsForList().rightPush(key, valueJson);
} catch (JsonProcessingException e) {
log.error("序列化对象出错:", e);
}
}
public Object popFromList(String key, Class<?> valueType) {
String valueJson = (String) redisTemplate.opsForList().leftPop(key);
if (valueJson != null) {
try {
return objectMapper.readValue(valueJson, valueType);
} catch (JsonProcessingException e) {
log.error("反序列化对象出错:", e);
}
}
return null;
}
}