mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
报表基础模块:1、模拟前端保存、获取模板列表、查询模板详情接口对接及啊对应字段的调整;2、移除没用部分引用和代码(积木等);
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
package com.cf.imes.framework.mybatis.core.type;
|
||||
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* mb自定义压缩列表类型转换器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/10 10:51
|
||||
*/
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR)
|
||||
@MappedTypes(List.class)
|
||||
public class CompressObjectListTypeHandler extends BaseTypeHandler<List<?>> {
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<?> parameter, JdbcType jdbcType) throws SQLException {
|
||||
try {
|
||||
String jsonString = objectMapper.writeValueAsString(parameter);
|
||||
// 压缩
|
||||
String compressJsonString = JsonUtils.zipString(jsonString);
|
||||
ps.setString(i, compressJsonString);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException("Error serializing List<Object> to JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String jsonStr = rs.getString(columnName);
|
||||
return parseJson(jsonStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String jsonStr = rs.getString(columnIndex);
|
||||
return parseJson(jsonStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String jsonStr = cs.getString(columnIndex);
|
||||
return parseJson(jsonStr);
|
||||
}
|
||||
|
||||
private List<?> parseJson(String jsonStr) {
|
||||
if (jsonStr == null || jsonStr.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
// Using JavaType to handle List<Object> deserialization
|
||||
JavaType javaType = objectMapper.getTypeFactory().constructCollectionType(List.class, Object.class);
|
||||
// 解压
|
||||
String compressJsonString = JsonUtils.unzipString(jsonStr);
|
||||
return objectMapper.readValue(compressJsonString, javaType);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error deserializing JSON to List<Object>", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.cf.imes.framework.mybatis.core.type;
|
||||
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.StringTypeHandler;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* mb自定义压缩字符串类型转换器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/10 16:05
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String compressedString = rs.getString(columnName);
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String compressedString = rs.getString(columnIndex);
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String compressedString = cs.getString(columnIndex);
|
||||
return JsonUtils.unzipString(compressedString);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user