mirror of https://gitee.com/xiaonuobase/snowy
【更新】添加easy trans依赖,Mp升级到3.5.2
parent
085ee5539d
commit
bfab7cf0f2
|
@ -17,7 +17,8 @@
|
|||
<properties>
|
||||
<lombok.versin>1.18.22</lombok.versin>
|
||||
<druid.version>1.2.8</druid.version>
|
||||
<mybatis.plus.version>3.5.1</mybatis.plus.version>
|
||||
<mybatis.plus.version>3.5.2</mybatis.plus.version>
|
||||
<easy.trans.version>2.0.3</easy.trans.version>
|
||||
<commons.pool2.version>2.11.1</commons.pool2.version>
|
||||
<hutool.version>5.7.22</hutool.version>
|
||||
<pinyin.version>2.5.1</pinyin.version>
|
||||
|
@ -79,6 +80,43 @@
|
|||
<version>${mybatis.plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- easy-trans 排除自带MP版本使用最新版本 -->
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId>
|
||||
<artifactId>easy-trans-spring-boot-starter</artifactId>
|
||||
<version>${easy.trans.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<groupId>com.baomidou</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-schema</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId>
|
||||
<artifactId>easy-trans-mybatis-plus-extend</artifactId>
|
||||
<version>${easy.trans.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>mybatis-plus-core</artifactId>
|
||||
<groupId>com.baomidou</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<groupId>com.baomidou</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-schema</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package vip.xiaonuo.common.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import vip.xiaonuo.common.util.CommonCryptogramUtil;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Sm4Cbc加解密
|
||||
* @author wanglei
|
||||
* @date 2022/9/30 15:24
|
||||
**/
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR)
|
||||
public class Sm4CbcTypeHandler <T> extends BaseTypeHandler<T> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setString(i, CommonCryptogramUtil.doSm4CbcEncrypt((String)parameter));
|
||||
}
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String columnValue = rs.getString(columnName);
|
||||
//有一些可能是空字符
|
||||
return StringUtils.isBlank(columnValue) ? (T)columnValue : (T)CommonCryptogramUtil.doSm4CbcDecrypt(columnValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String columnValue = rs.getString(columnIndex);
|
||||
return StringUtils.isBlank(columnValue) ? (T)columnValue : (T)CommonCryptogramUtil.doSm4CbcDecrypt(columnValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String columnValue = cs.getString(columnIndex);
|
||||
return StringUtils.isBlank(columnValue) ? (T)columnValue : (T)CommonCryptogramUtil.doSm4CbcDecrypt(columnValue);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue