Commit 21b7e55608e87de2930ed435af8f50d27dc979c9
1 parent
05eb2cdd39
Exists in
master
and in
6 other branches
update
Showing 2 changed files with 16 additions and 2 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java
View file @
21b7e55
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | import com.lyms.platform.permission.model.LisReportModel; |
| 10 | 10 | import com.lyms.platform.permission.service.LisService; |
| 11 | 11 | import org.apache.commons.collections.CollectionUtils; |
| 12 | +import org.codehaus.jackson.type.TypeReference; | |
| 12 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | 14 | import org.springframework.stereotype.Service; |
| 14 | 15 | |
| ... | ... | @@ -24,8 +25,8 @@ |
| 24 | 25 | @Override |
| 25 | 26 | public BaseResponse saveLisData(String lisData) { |
| 26 | 27 | |
| 27 | - List<LisReportModel> lisList = JsonUtil.toList(lisData, LisReportModel.class); | |
| 28 | - System.out.println(); | |
| 28 | + List<LisReportModel> lisList =JsonUtil.jkstr2List(lisData, new TypeReference<List<LisReportModel>>() {}); | |
| 29 | + System.out.println(lisList); | |
| 29 | 30 | |
| 30 | 31 | if (CollectionUtils.isNotEmpty(lisList)) |
| 31 | 32 | { |
platform-common/src/main/java/com/lyms/platform/common/utils/JsonUtil.java
View file @
21b7e55
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | import net.sf.json.JSONObject; |
| 9 | 9 | import org.apache.commons.lang.StringUtils; |
| 10 | 10 | import org.codehaus.jackson.map.ObjectMapper; |
| 11 | +import org.codehaus.jackson.type.TypeReference; | |
| 11 | 12 | import org.springframework.data.mongodb.core.query.Update; |
| 12 | 13 | |
| 13 | 14 | import java.io.IOException; |
| ... | ... | @@ -21,6 +22,18 @@ |
| 21 | 22 | objectMapper.setDateFormat(DateUtil.y_m_d_h_m_s); |
| 22 | 23 | try { |
| 23 | 24 | return (T) objectMapper.readValue(content, cls); |
| 25 | + } catch (IOException e) { | |
| 26 | + e.printStackTrace(); | |
| 27 | + } | |
| 28 | + return null; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public static <T> T jkstr2List(String content, | |
| 32 | + TypeReference<?> typeReference) { | |
| 33 | + ObjectMapper objectMapper = new ObjectMapper(); | |
| 34 | + objectMapper.setDateFormat(DateUtil.y_m_d_h_m_s); | |
| 35 | + try { | |
| 36 | + return objectMapper.readValue(content,typeReference); | |
| 24 | 37 | } catch (IOException e) { |
| 25 | 38 | e.printStackTrace(); |
| 26 | 39 | } |