ソースを参照

优化地区处理工具类

woody 9 ヶ月 前
コミット
d7c203a51a

+ 24 - 4
framework-common/src/main/java/com/chelvc/framework/common/model/Region.java

@@ -160,8 +160,28 @@ public final class Region implements Serializable {
      * @param code 地区编码
      * @param code 地区编码
      * @return 地区编码
      * @return 地区编码
      */
      */
-    public static int code2city(int code) {
-        return code / 100 * 100;
+    public static Long code2city(Long code) {
+        return code == null ? null : code / 100 * 100;
+    }
+
+    /**
+     * 将地区编码转换成市级编码
+     *
+     * @param code 地区编码
+     * @return 地区编码
+     */
+    public static Integer code2city(Integer code) {
+        return code == null ? null : code / 100 * 100;
+    }
+
+    /**
+     * 将地区编码转换成省级编码
+     *
+     * @param code 地区编码
+     * @return 地区编码
+     */
+    public static Long code2province(Long code) {
+        return code == null ? null : code / 10000 * 10000;
     }
     }
 
 
     /**
     /**
@@ -170,8 +190,8 @@ public final class Region implements Serializable {
      * @param code 地区编码
      * @param code 地区编码
      * @return 地区编码
      * @return 地区编码
      */
      */
-    public static int code2province(int code) {
-        return code / 10000 * 10000;
+    public static Integer code2province(Integer code) {
+        return code == null ? null : code / 10000 * 10000;
     }
     }
 
 
     /**
     /**