From ad4aa3dea3554b168824e426e66bd9849e3193d4 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 20 六月 2019 17:08:43 +0800
Subject: [PATCH] 文档重新整理加入 开发环境搭建和生产环境搭建步骤

---
 java110-common/src/main/java/com/java110/common/util/CommonUtil.java |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/java110-common/src/main/java/com/java110/common/util/CommonUtil.java b/java110-common/src/main/java/com/java110/common/util/CommonUtil.java
index 4329513..06f4fcf 100644
--- a/java110-common/src/main/java/com/java110/common/util/CommonUtil.java
+++ b/java110-common/src/main/java/com/java110/common/util/CommonUtil.java
@@ -16,10 +16,11 @@
     /**
      * 灏� 30*1000 杞负 30000
      * 涓嶈兘鍑虹幇灏忔暟鐐圭瓑
+     *
      * @param val
      * @return
      */
-    public static int multiplicativeStringToInteger(String val){
+    public static int multiplicativeStringToInteger(String val) {
         try {
             if (StringUtils.isEmpty(val)) {
                 return 0;
@@ -27,19 +28,19 @@
             if (val.contains("*")) {
                 String[] vals = val.split("\\*");
                 int value = 1;
-                for(int vIndex = 0 ; vIndex < vals.length;vIndex++){
-                    if(!NumberUtils.isNumber(vals[vIndex])){
+                for (int vIndex = 0; vIndex < vals.length; vIndex++) {
+                    if (!NumberUtils.isNumber(vals[vIndex])) {
                         throw new ClassCastException("閰嶇疆鐨勬暟鎹湁闂锛屽繀椤婚厤缃负30*1000鏍煎紡");
                     }
                     value *= Integer.parseInt(vals[vIndex]);
                 }
                 return value;
             }
-            if(NumberUtils.isNumber(val)){
+            if (NumberUtils.isNumber(val)) {
                 return Integer.parseInt(val);
             }
-        }catch (Exception e){
-            logger.error("---------------[CommonUtil.multiplicativeStringToInteger]----------------绫诲瀷杞崲澶辫触",e);
+        } catch (Exception e) {
+            logger.error("---------------[CommonUtil.multiplicativeStringToInteger]----------------绫诲瀷杞崲澶辫触", e);
             return 0;
         }
         return 0;
@@ -47,19 +48,36 @@
 
     /**
      * 鐢熸垚鍏綅楠岃瘉鐮�
+     *
      * @return
      */
-    public static String generateVerificationCode(){
+    public static String generateVerificationCode() {
         Random random = new Random();
 
-        String result="";
-        for(int i=0;i<6;i++){
-            result+=random.nextInt(10);
+        String result = "";
+        for (int i = 0; i < 6; i++) {
+            result += random.nextInt(10);
         }
 
         return result;
     }
 
+    // 鎵嬫満鍙风爜鍓嶄笁鍚庡洓鑴辨晱
+    public static String mobileEncrypt(String mobile) {
+        if (StringUtils.isEmpty(mobile) || (mobile.length() != 11)) {
+            return mobile;
+        }
+        return mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
+    }
+
+    //韬唤璇佸墠涓夊悗鍥涜劚鏁�
+    public static String idEncrypt(String id) {
+        if (StringUtils.isEmpty(id) || (id.length() < 8)) {
+            return id;
+        }
+        return id.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
+    }
+
 
     //鏁堥獙
     public static boolean sqlValidate(String str) {

--
Gitblit v1.8.0