提交 5a9b9281 authored 作者: 李炎's avatar 李炎

微调

上级 e9f8fd94
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,8 +3,8 @@
<mapper namespace="com.system.dao.LicInfoMapper">
<resultMap id="BaseResultMap" type="com.system.transfer.lic.LicInfoListOutVoRecords">
<!--<result column="module_verification" property="moduleVerification" jdbcType="VARCHAR"-->
<!--typeHandler="com.system.handler.JacksonTypeHandler"/>-->
<result column="module_verification" property="moduleVerification" jdbcType="VARCHAR"
typeHandler="com.system.handler.JacksonTypeHandler"/>
<result column="docker_services" property="dockerServices" jdbcType="LONGVARCHAR"
typeHandler="com.system.handler.DockerServiceDtoTypeHandler"/>
</resultMap>
......@@ -14,6 +14,7 @@
SELECT
id, lq_lic_name, mac_address, effective_time, file_effective_time, verification_interval, module_verification,
docker_services,
remark, create_time
FROM tb_lic_info
<where>
......
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.system.dto.DockerServiceDto;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
......@@ -27,7 +28,7 @@ import java.util.List;
*/
//@MappedTypes({JSONArray.class}) // 因为BaseTypeHandler<JSONArray> 泛型中指定了JSONArray 的话,这个注解也可以省略
@MappedJdbcTypes(value = JdbcType.LONGVARCHAR, includeNullJdbcType = true)
//@Component
@Component
public class DockerServiceDtoTypeHandler extends BaseTypeHandler<List<DockerServiceDto>> implements InitializingBean {
static DockerServiceDtoTypeHandler j;
@Autowired
......@@ -70,6 +71,6 @@ public class DockerServiceDtoTypeHandler extends BaseTypeHandler<List<DockerServ
@SneakyThrows
private List<DockerServiceDto> read(String json) {
return json != null ? Arrays.asList(j.objectMapper.readValue(json, DockerServiceDto[].class)) : new ArrayList<>();
return !StringUtils.isEmpty(json) ? Arrays.asList(j.objectMapper.readValue(json, DockerServiceDto[].class)) : new ArrayList<>();
}
}
......@@ -6,6 +6,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -16,7 +18,7 @@ import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
/**
JSON 字段类型处理器
* JSON 字段类型处理器
**/
@Slf4j
@MappedJdbcTypes(JdbcType.VARCHAR)
......@@ -74,8 +76,13 @@ public class JacksonTypeHandler<T extends Object> extends BaseTypeHandler<T> {
}
@Override
// public void setNonNullParameter(PreparedStatement ps, int columnIndex, T parameter, JdbcType jdbcType)
// throws SQLException {
// ps.setString(columnIndex, toJsonString(parameter));
// }
public void setNonNullParameter(PreparedStatement ps, int columnIndex, T parameter, JdbcType jdbcType)
throws SQLException {
ps.setString(columnIndex, toJsonString(parameter));
ps.setString(columnIndex, parameter != null ? JSON.toJSONString(parameter, SerializerFeature.WriteMapNullValue) : "[]");
}
}
......@@ -48,7 +48,7 @@ public class LicInfoUpdateInVo {
/**
* 模块验证
*/
private String moduleVerification;
private List<String> moduleVerification;
/**
* 服务
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论