12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package com.persagy.bdtp.adm.entity;
- import cn.hutool.core.util.StrUtil;
- import com.baomidou.mybatisplus.annotation.TableField;
- import com.baomidou.mybatisplus.annotation.TableName;
- import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.fasterxml.jackson.databind.JsonNode;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.databind.node.ObjectNode;
- import com.persagy.dmp.common.helper.SpringHelper;
- import lombok.Data;
- import java.io.IOException;
- @Data
- @TableName(value = "adm_config",autoResultMap = true)
- public class AdmConfig implements IAdmEntity {
- private String id;
- private String projectId;
- private String name;
- private String code;
- @TableField(
- typeHandler = JacksonTypeHandler.class
- )
- private JsonNode data;
- private String strData;
- @Override
- public void serializeJsonProp() {
- if(data != null) {
- ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
- try {
- strData = objectMapper.writeValueAsString(data);
- } catch (JsonProcessingException e) {
- }
- data = null;
- }
- }
- @Override
- public void deserializeJsonProp() {
- if(StrUtil.isNotBlank(strData)) {
- ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
- try {
- data = objectMapper.readValue(strData, JsonNode.class);
- } catch (IOException e) {
- }
- strData = null;
- }
- }
- }
|