From 8d4636cc30e093fb7526cb75180eee10c5b8281f Mon Sep 17 00:00:00 2001
From: fhx <308050795@qq.com>
Date: 星期五, 20 九月 2024 18:47:18 +0800
Subject: [PATCH] Merge branch 'master-stander' into master-jiayan

---
 src/main/java/com/hx/util/MapUtil.java |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/hx/util/MapUtil.java b/src/main/java/com/hx/util/MapUtil.java
index 22ae85c..392bae2 100644
--- a/src/main/java/com/hx/util/MapUtil.java
+++ b/src/main/java/com/hx/util/MapUtil.java
@@ -1,5 +1,6 @@
 package com.hx.util;
 
+import java.math.BigDecimal;
 import java.util.Map;
 
 /**
@@ -34,12 +35,12 @@
      */
     public static int getInt(Map<String, Object> map, String key)
     {
-        if(map == null || StringUtils.isEmpty(key))
+        if(map == null || StringUtils.isEmpty(key) || null == map.get(key) || StringUtils.isEmpty(map.get(key).toString()))
         {
             return -1;
         }
 
-        return null == map.get(key) ? -1 : Integer.parseInt(map.get(key).toString());
+        return Integer.parseInt(map.get(key).toString());
     }
 
     /**
@@ -50,11 +51,43 @@
      */
     public static int getIntZero(Map<String, Object> map, String key)
     {
-        if(map == null || StringUtils.isEmpty(key))
+        if(map == null || StringUtils.isEmpty(key) || null == map.get(key) || StringUtils.isEmpty(map.get(key).toString()))
         {
             return 0;
         }
 
-        return null == map.get(key) ? 0 : Integer.parseInt(map.get(key).toString());
+        return Integer.parseInt(map.get(key).toString());
+    }
+
+    /**
+     * 浠巑ap涓幏鍙栨暟瀛楃被鍨嬪璞�
+     * @param map
+     * @param key
+     * @return
+     */
+    public static BigDecimal getBigDecimal(Map<String, Object> map, String key)
+    {
+        if(map == null || StringUtils.isEmpty(key))
+        {
+            return BigDecimal.ZERO;
+        }
+
+        return null == map.get(key) ? BigDecimal.ZERO : new BigDecimal(map.get(key).toString());
+    }
+
+    /**
+     * 鑾峰彇娴偣鏁帮紝榛樿杩斿洖0
+     * @param map
+     * @param key
+     * @return
+     */
+    public static Double getDoubleZero(Map<String, Object> map, String key)
+    {
+        if(map == null || StringUtils.isEmpty(key))
+        {
+            return 0D;
+        }
+
+        return null == map.get(key) ? 0D : Double.parseDouble(map.get(key).toString());
     }
 }

--
Gitblit v1.8.0