| @@ -11,11 +11,13 @@ import org.springframework.data.redis.core.ValueOperations; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.alibaba.fastjson.TypeReference; | import com.alibaba.fastjson.TypeReference; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| public class RedisCacheUtils { | public class RedisCacheUtils { | ||||
| private static <T> T parseJson(String json,Class<T> clazz) { | private static <T> T parseJson(String json,Class<T> clazz) { | ||||
| return JSON.parseObject(json,new TypeReference<T>() {}); | |||||
| return JSON.parseObject(json,clazz); | |||||
| } | } | ||||
| private static <T> List<T> parseListJson(String json,Class<T> clazz) { | private static <T> List<T> parseListJson(String json,Class<T> clazz) { | ||||
| @@ -63,12 +65,7 @@ public class RedisCacheUtils { | |||||
| } | } | ||||
| public static Map getCacheMap(RedisTemplate<String, Object> template,String key) { | public static Map getCacheMap(RedisTemplate<String, Object> template,String key) { | ||||
| if (template.hasKey(key)) { | |||||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||||
| Object o = operations.get(key); | |||||
| return parseJson(JSON.toJSONString(o), Map.class); | |||||
| } | |||||
| return null; | |||||
| return getCacheObject(template,key,Map.class); | |||||
| } | } | ||||
| public static String getCacheString(RedisTemplate<String, Object> template,String key) { | public static String getCacheString(RedisTemplate<String, Object> template,String key) { | ||||
| @@ -129,13 +126,7 @@ public class RedisCacheUtils { | |||||
| } | } | ||||
| public static Map getMapFieldObject(Object o,String property) { | public static Map getMapFieldObject(Object o,String property) { | ||||
| String json = JSON.toJSONString(o); | |||||
| JSONObject jsonObject = JSON.parseObject(json); | |||||
| Object p = jsonObject.get(property); | |||||
| if (null != p ) { | |||||
| return parseJson(JSON.toJSONString(p), Map.class); | |||||
| } | |||||
| return null; | |||||
| return getFieldObject(o,property,Map.class); | |||||
| } | } | ||||
| public static void removeCache(RedisTemplate<String, Object> template,String key) { | public static void removeCache(RedisTemplate<String, Object> template,String key) { | ||||