Commit 061e4d46 authored by 张辰's avatar 张辰

fix json bug

parent c6f57eff
package com.tanpu.community.manager; package com.tanpu.community.manager;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException; import com.tanpu.common.exception.BizException;
...@@ -94,7 +95,8 @@ public class ThemeManager { ...@@ -94,7 +95,8 @@ public class ThemeManager {
List<String> excludeIds; List<String> excludeIds;
if (pageNo > 1) { if (pageNo > 1) {
String l = redisCache.get("themeFullSearch_" + ident); String l = redisCache.get("themeFullSearch_" + ident);
excludeIds = StringUtils.isBlank(l) ? new ArrayList<>() : JSON.parseArray(l, String.class); excludeIds = StringUtils.isBlank(l) ? new ArrayList<>() : JsonUtil.toBean(l, new TypeReference<List<String>>() {
});
} else { } else {
excludeIds = new ArrayList<>(); excludeIds = new ArrayList<>();
} }
...@@ -126,7 +128,7 @@ public class ThemeManager { ...@@ -126,7 +128,7 @@ public class ThemeManager {
} }
excludeIds.addAll(resp.themes.stream().map(ThemeQo::getThemeId).collect(Collectors.toList())); excludeIds.addAll(resp.themes.stream().map(ThemeQo::getThemeId).collect(Collectors.toList()));
redisCache.put("themeFullSearch_" + ident, JSON.toJSONString(excludeIds), 60 * 60 * 6); redisCache.put("themeFullSearch_" + ident, JsonUtil.toJson(excludeIds), 60 * 60 * 6);
return resp; return resp;
} }
...@@ -206,7 +208,8 @@ public class ThemeManager { ...@@ -206,7 +208,8 @@ public class ThemeManager {
List<String> excludeIds; List<String> excludeIds;
if (req.page.pageNumber > 1) { if (req.page.pageNumber > 1) {
String l = redisCache.get("queryThemes_" + req.ident); String l = redisCache.get("queryThemes_" + req.ident);
excludeIds = StringUtils.isBlank(l) ? new ArrayList<>() : JSON.parseArray(l, String.class); excludeIds = StringUtils.isBlank(l) ? new ArrayList<>() : JsonUtil.toBean(l, new TypeReference<List<String>>() {
});
} else { } else {
excludeIds = new ArrayList<>(); excludeIds = new ArrayList<>();
} }
...@@ -261,7 +264,7 @@ public class ThemeManager { ...@@ -261,7 +264,7 @@ public class ThemeManager {
resp.themes = convertEntityToQo(themes, userId); resp.themes = convertEntityToQo(themes, userId);
excludeIds.addAll(resp.themes.stream().map(ThemeQo::getThemeId).collect(Collectors.toList())); excludeIds.addAll(resp.themes.stream().map(ThemeQo::getThemeId).collect(Collectors.toList()));
redisCache.put("queryThemes_" + req.ident, JSON.toJSONString(excludeIds), 60 * 60 * 6); redisCache.put("queryThemes_" + req.ident, JsonUtil.toJson(excludeIds), 60 * 60 * 6);
//组装详情 //组装详情
return resp; return resp;
......
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