Browse Source

fix encode

he2802 2 năm trước cách đây
mục cha
commit
fc6d4c495e

+ 1 - 1
zhongzheng-admin/src/main/resources/application.yml

@@ -141,7 +141,7 @@ mybatis-plus:
   executorType: SIMPLE
   # 指定外部化 MyBatis Properties 配置,通过该配置可以抽离配置,实现不同环境的配置部署
   configurationProperties: null
-  type-handlers-package: com.zhongzheng.common.type
+  typeHandlersPackage: com.zhongzheng.common.type
   configuration:
     # 自动驼峰命名规则(camel case)映射
     # 如果您的数据库命名符合规则无需使用 @TableField 注解指定数据库字段名

+ 1 - 0
zhongzheng-api/src/main/resources/application.yml

@@ -138,6 +138,7 @@ mybatis-plus:
   executorType: SIMPLE
   # 指定外部化 MyBatis Properties 配置,通过该配置可以抽离配置,实现不同环境的配置部署
   configurationProperties: null
+  typeHandlersPackage: com.zhongzheng.common.type
   configuration:
     # 自动驼峰命名规则(camel case)映射
     # 如果您的数据库命名符合规则无需使用 @TableField 注解指定数据库字段名

+ 16 - 4
zhongzheng-common/src/main/java/com/zhongzheng/common/type/EncryptHandler.java

@@ -13,7 +13,7 @@ import java.sql.SQLException;
 
 
 @MappedJdbcTypes(JdbcType.VARCHAR)
-public class EncryptHandler implements TypeHandler<String> {
+public class EncryptHandler  implements TypeHandler<String> {
     /**
      * 线上运行后勿修改,会影响已加密数据解密
      */
@@ -31,20 +31,30 @@ public class EncryptHandler implements TypeHandler<String> {
         return SecureUtil.aes(KEYS).decryptStr(value);
     }
 
+    public static String encrypt(String value){
+        if (null == value) {
+            return null;
+        }
+        AES aes = SecureUtil.aes(KEYS);
+        String encrypt = aes.encryptHex(value);
+        return encrypt;
+    }
+
     @Override
     public void setParameter(PreparedStatement preparedStatement, int i, String s, JdbcType jdbcType) throws SQLException {
         if (StringUtils.isEmpty(s)) {
             preparedStatement.setString(i, null);
             return;
         }
-        AES aes = SecureUtil.aes(KEYS);
-        String encrypt = aes.encryptHex(s);
-        preparedStatement.setString(i, encrypt);
+        preparedStatement.setString(i, s);
+    //    String encrypt = encrypt(s);
+    //    preparedStatement.setString(i, encrypt);
     }
 
     @Override
     public String getResult(ResultSet resultSet, String s) throws SQLException {
         return decrypt(resultSet.getString(s));
+    //    return decrypt(resultSet.getString(s));
     }
 
     @Override
@@ -56,4 +66,6 @@ public class EncryptHandler implements TypeHandler<String> {
     public String getResult(CallableStatement callableStatement, int i) throws SQLException {
         return null;
     }
+
+
 }

+ 1 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -22,6 +22,7 @@ import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.enums.UserStatus;
 import com.zhongzheng.common.exception.BaseException;
 import com.zhongzheng.common.exception.CustomException;
+import com.zhongzheng.common.type.EncryptHandler;
 import com.zhongzheng.common.utils.*;
 import com.zhongzheng.common.utils.ip.IpUtils;
 import com.zhongzheng.modules.alisms.service.IAliSmsService;