From 0344dc66783353faff118a0ea91f7d2aa07bbd4a Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期六, 02 四月 2022 18:47:44 +0800
Subject: [PATCH] 优化加密初始化方法

---
 src/main/java/com/hx/util/SimpleTool.java |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/SimpleTool.java b/src/main/java/com/hx/util/SimpleTool.java
index 8793c5c..fd0764b 100644
--- a/src/main/java/com/hx/util/SimpleTool.java
+++ b/src/main/java/com/hx/util/SimpleTool.java
@@ -43,6 +43,7 @@
 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 {
 
@@ -59,6 +60,45 @@
     }
 
     /**
+     * 灏嗗璞¤鎹负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 鐗瑰畾鏍煎紡鐨凧SONObject

--
Gitblit v1.8.0