fix: 最近动态

This commit is contained in:
zlg
2024-07-23 21:39:52 +08:00
parent 24a1eea67d
commit 5584bb81da
2 changed files with 9 additions and 4 deletions

View File

@@ -167,10 +167,14 @@ public class SchisandraShareDetailController {
);
String value = "您最近创建了一个分享:" + schisandraShareDetailDTO.getTitle();
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH·mm·ss");
String formattedDate = dateFormat.format(date);
HashMap<String,String> map1 = new HashMap<>();
map1.put("title",value);
map1.put("date",formattedDate);
Gson gson1=new Gson();
String key = redisUtil.buildKey(SHARE_USER_RECENT, schisandraShareDetailDTO.getUserId(), formattedDate);
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
redisUtil.setNx(key, gson1.toJson(map1), 30L, TimeUnit.DAYS);
return Result.ok();
}
return Result.fail();

View File

@@ -1,5 +1,6 @@
package com.schisandra.share.common.redis;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
@@ -59,8 +60,8 @@ public class RedisUtil {
keys.forEach(key->{
HashMap<Object,Object> map=new HashMap<>();
String value= (String) redisTemplate.opsForValue().get(key);
map.put(key,value);
keysList.add(map);
Gson gson=new Gson();
keysList.add(gson.fromJson(value,HashMap.class));
});
return keysList;
}