fix: 最近动态
This commit is contained in:
@@ -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();
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user