| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.dto.community.CommunityDto; |
| | | import org.apache.commons.beanutils.ConvertUtils; |
| | | import org.apache.commons.beanutils.Converter; |
| | | import org.apache.commons.lang3.reflect.FieldUtils; |
| | |
| | | */ |
| | | public static <T1, T2> T2 covertBean(T1 orgBean, T2 dstBean) { |
| | | |
| | | if(orgBean == null){ |
| | | return dstBean; |
| | | } |
| | | |
| | | try { |
| | | //BeanUtils.copyProperties(dstBean, orgBean); |
| | | if (orgBean instanceof Map) { |
| | |
| | | //System.out.println("字段类型" + dstClass); |
| | | |
| | | Object value = orgMap.get(field.getName()); |
| | | if(value == null){ |
| | | continue; |
| | | } |
| | | //String 转date |
| | | Object tmpValue = Java110Converter.getValue(value, dstClass); |
| | | //System.out.println("tmpValue"+value.toString()); |
| | |
| | | } |
| | | return newMaps; |
| | | } |
| | | public static List<Map<String, Object>> beanCovertMapListC(List<CommunityDto> orgBeans) { |
| | | List<Map<String, Object>> newMaps = new ArrayList<Map<String, Object>>(); |
| | | Map<String, Object> newMap = null; |
| | | for (Object orgbean : orgBeans) { |
| | | newMap = beanCovertMap(orgbean); |
| | | newMaps.add(newMap); |
| | | } |
| | | return newMaps; |
| | | } |
| | | } |