Commit 2f4aa601 authored by alex yao's avatar alex yao

fix:NPE

parent a38cec25
...@@ -55,7 +55,7 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction { ...@@ -55,7 +55,7 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
JSONObject jsonObject = new JSONObject(content); JSONObject jsonObject = new JSONObject(content);
// 提取 content // 提取 content
String contents = jsonObject.getStr("content"); String contents = jsonObject.getStr("content");
String contentKey = SetLongMemoryConstants.REDIS_PREFIX + key + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String contentKey = SetLongMemoryConstants.REDIS_PREFIX + key;
redisService.hset(contentKey, DateUtils.getCurrTime(), contents, expireTime); redisService.hset(contentKey, DateUtils.getCurrTime(), contents, expireTime);
return "SUCCESS"; return "SUCCESS";
} }
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
public class MemoryVariableWriter { public class MemoryVariableWriter {
public static Map<Object, Object> get(String key) { public static Map<Object, Object> get(String key) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key;
RedisService redisService = SpringUtils.getBean(RedisService.class); RedisService redisService = SpringUtils.getBean(RedisService.class);
if (!redisService.hasKey(redisKey)) { if (!redisService.hasKey(redisKey)) {
return null; return null;
...@@ -22,25 +22,25 @@ public class MemoryVariableWriter { ...@@ -22,25 +22,25 @@ public class MemoryVariableWriter {
} }
public static void clean(String key) { public static void clean(String key) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key;
RedisService redisService = SpringUtils.getBean(RedisService.class); RedisService redisService = SpringUtils.getBean(RedisService.class);
redisService.del(redisKey); redisService.del(redisKey);
} }
public static void cleanByPre(String key) { public static void cleanByPre(String key) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key + ":"; String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + key;
RedisService redisService = SpringUtils.getBean(RedisService.class); RedisService redisService = SpringUtils.getBean(RedisService.class);
redisService.delByPre(redisKey); redisService.delByPre(redisKey);
} }
public static void delItem(String identifier, String... items) { public static void delItem(String identifier, String... items) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier;
RedisService redisService = SpringUtils.getBean(RedisService.class); RedisService redisService = SpringUtils.getBean(RedisService.class);
redisService.hdel(redisKey, items); redisService.hdel(redisKey, items);
} }
public static void addItem(String identifier, Map<String, Object> map) { public static void addItem(String identifier, Map<String, Object> map) {
String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String redisKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier;
RedisService redisService = SpringUtils.getBean(RedisService.class); RedisService redisService = SpringUtils.getBean(RedisService.class);
// 创建 JSONObject 对象 // 创建 JSONObject 对象
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
......
...@@ -45,7 +45,7 @@ public class MemoryVariableWriterFunction extends AbstractLargeModelFunction { ...@@ -45,7 +45,7 @@ public class MemoryVariableWriterFunction extends AbstractLargeModelFunction {
if (StringUtils.isBlank(content) || StringUtils.isBlank(identifier)) { if (StringUtils.isBlank(content) || StringUtils.isBlank(identifier)) {
return "FAIL"; return "FAIL";
} }
String contentKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String contentKey = MemoryVariableWriterConstants.REDIS_PREFIX + identifier;
// 创建 JSONObject 对象 // 创建 JSONObject 对象
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (redisService.hasKey(contentKey)) { if (redisService.hasKey(contentKey)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment