|
@@ -24,6 +24,7 @@ import com.fdkankan.redis.constant.RedisLockKey;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.IconBean;
|
|
|
+import com.fdkankan.scene.bean.TagBean;
|
|
|
import com.fdkankan.scene.entity.*;
|
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
|
import com.fdkankan.scene.service.*;
|
|
@@ -2312,8 +2313,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
@Override
|
|
|
public ResultData listTags(String num) throws Exception{
|
|
|
|
|
|
+ //保证热点数据安全性,当redis宕机导致热点数据丢失时,可以从文件中读取,恢复到redis
|
|
|
this.syncHotFromFileToRedis(num);
|
|
|
|
|
|
+ //保证icons数据安全性,当redis宕机导致icons数据丢失时,可以从文件中读取,恢复到redis
|
|
|
this.syncIconsFromFileToRedis(num);
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
@@ -2322,14 +2325,24 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
String key = String.format(RedisKey.SCENE_HOT_DATA, num);
|
|
|
Map<String, String> allTagsMap = redisUtil.hmget(key);
|
|
|
List<JSONObject> tags = Lists.newArrayList();
|
|
|
+ List<TagBean> tagBeanList = new ArrayList<>();
|
|
|
if(CollUtil.isNotEmpty(allTagsMap)){
|
|
|
- tags = allTagsMap.entrySet().parallelStream().map(entry -> {
|
|
|
+ allTagsMap.entrySet().stream().forEach(entry -> {
|
|
|
JSONObject jsonObject = JSON.parseObject(entry.getValue());
|
|
|
- return jsonObject;
|
|
|
+ tagBeanList.add(
|
|
|
+ TagBean.builder()
|
|
|
+ .createTime(jsonObject.getLong("createTime"))
|
|
|
+ .tag(jsonObject).build());
|
|
|
+ });
|
|
|
+ //按创建时间倒叙排序
|
|
|
+ tagBeanList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
|
|
|
+
|
|
|
+ //移除createTime字段
|
|
|
+ tags = tagBeanList.stream().map(tagBean -> {
|
|
|
+ JSONObject tag = tagBean.getTag();
|
|
|
+ tag.remove("createTime");
|
|
|
+ return tag;
|
|
|
}).collect(Collectors.toList());
|
|
|
- //按时间倒叙排序
|
|
|
- Collections.sort(tags, Comparator.comparingLong(t -> t.getLongValue("createTime")));
|
|
|
- tags.parallelStream().forEach(t->t.remove("createTime"));
|
|
|
}
|
|
|
result.put("tags", tags);
|
|
|
|