| | |
| | | import net.sourceforge.pinyin4j.PinyinHelper; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; |
| | | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | |
| | | public class SimpleTool { |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 将对象装换为map |
| | | * |
| | | * @param bean |
| | | * @return |
| | | */ |
| | | public static <T> Map<String, Object> beanToMap(T bean) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | map.put(key + "", beanMap.get(key)); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 将对象装换为map |
| | | * |
| | | * @param bean |
| | | * @return |
| | | */ |
| | | public static Map<String, String> beanToMapS(Object bean) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | if(beanMap.get(key) != null){ |
| | | map.put(key + "", beanMap.get(key).toString()); |
| | | }else{ |
| | | map.put(key + "", ""); |
| | | } |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 后台格式构建返回值格式列表-后台获取列表 |
| | | * @param count 返回总条数 |
| | | * @return JSONObject 特定格式的JSONObject |