mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
+16
-5
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.framework.mybatis.core.type;
|
||||
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.StringTypeHandler;
|
||||
|
||||
@@ -19,25 +20,35 @@ public class CompressStringTypeHandler extends StringTypeHandler {
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType)
|
||||
throws SQLException {
|
||||
String compressString = JsonUtils.zipString(parameter);
|
||||
ps.setString(i, compressString);
|
||||
if (StringUtils.isNotEmpty(parameter)) {
|
||||
String compressString = JsonUtils.zipString(parameter);
|
||||
ps.setString(i, compressString);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String compressedString = rs.getString(columnName);
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
return unzipString(compressedString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String compressedString = rs.getString(columnIndex);
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
return unzipString(compressedString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String compressedString = cs.getString(columnIndex);
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
return unzipString(compressedString);
|
||||
}
|
||||
|
||||
private String unzipString(String compressedString) {
|
||||
if (StringUtils.isNotEmpty(compressedString)) {
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user