AdmInfosConfig.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package com.persagy.bdtp.adm.entity;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.baomidou.mybatisplus.annotation.TableField;
  4. import com.baomidou.mybatisplus.annotation.TableName;
  5. import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
  6. import com.fasterxml.jackson.core.JsonProcessingException;
  7. import com.fasterxml.jackson.databind.ObjectMapper;
  8. import com.persagy.dmp.common.helper.SpringHelper;
  9. import lombok.Data;
  10. import java.io.IOException;
  11. import java.util.List;
  12. @Data
  13. @TableName(value = "adm_infos_config",autoResultMap = true)
  14. public class AdmInfosConfig implements IAdmEntity {
  15. private String id;
  16. private String projectId;
  17. private String objType;
  18. private String name;
  19. private String classCode;
  20. private String majorCode;
  21. private String systemCode;
  22. @TableField(
  23. typeHandler = JacksonTypeHandler.class
  24. )
  25. private List<Object> infos;
  26. private String flag;
  27. private String strInfos;
  28. @Override
  29. public void serializeJsonProp() {
  30. if(infos != null) {
  31. ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
  32. try {
  33. strInfos = objectMapper.writeValueAsString(infos);
  34. } catch (JsonProcessingException e) {
  35. }
  36. infos = null;
  37. }
  38. }
  39. @Override
  40. public void deserializeJsonProp() {
  41. if(StrUtil.isNotBlank(strInfos)) {
  42. ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
  43. try {
  44. infos = objectMapper.readValue(strInfos, List.class);
  45. } catch (IOException e) {
  46. }
  47. strInfos = null;
  48. }
  49. }
  50. }