yangdamao 1 年之前
父节点
当前提交
b9bf31de74
共有 1 个文件被更改,包括 19 次插入15 次删除
  1. 19 15
      zhongzheng-common/src/main/java/com/zhongzheng/common/type/EncryptHandler.java

+ 19 - 15
zhongzheng-common/src/main/java/com/zhongzheng/common/type/EncryptHandler.java

@@ -5,6 +5,7 @@ import cn.hutool.crypto.symmetric.AES;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.utils.SecurityUtils;
+import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.TelPhoneUtils;
 import org.apache.ibatis.type.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,21 +40,24 @@ public class EncryptHandler  implements TypeHandler<String> {
             return value;
         }
         String s = SecureUtil.aes(KEYS).decryptStr(value);
-        Boolean phoneConceal = false;
-        try (InputStream inputStream = EncryptHandler.class.getClassLoader().getResourceAsStream("application.yml")) {
-            Properties properties = new Properties();
-            properties.load(inputStream);
-            String property = properties.getProperty("conceal");
-            phoneConceal = Boolean.valueOf(property);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        if (phoneConceal){
-            //开启手机号码加密
-            LoginUser loginUser = SecurityUtils.getLoginUser();
-            if (s.length() <= 11 &&
-                    (ObjectUtils.isNull(loginUser.getPhoneConcealSign()) || loginUser.getPhoneConcealSign() != 1)){
-                return TelPhoneUtils.hideTelPhone(s);
+        String authorizationToken = ServletUtils.getRequest().getHeader("AuthorizationToken");
+        if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(authorizationToken)){
+            Boolean phoneConceal = false;
+            try (InputStream inputStream = EncryptHandler.class.getClassLoader().getResourceAsStream("application.yml")) {
+                Properties properties = new Properties();
+                properties.load(inputStream);
+                String property = properties.getProperty("conceal");
+                phoneConceal = Boolean.valueOf(property);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            if (phoneConceal){
+                //开启手机号码加密
+                LoginUser loginUser = SecurityUtils.getLoginUser();
+                if (s.length() <= 11 &&
+                        (ObjectUtils.isNull(loginUser.getPhoneConcealSign()) || loginUser.getPhoneConcealSign() != 1)){
+                    return TelPhoneUtils.hideTelPhone(s);
+                }
             }
         }
         return s;