REQ-2135: ignore empty field when parse and serialize JSON

This commit is contained in:
yanglin 2024-04-03 11:19:26 +08:00
parent 19de5ff2df
commit bb80e882d9
5 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package cn.axzo.msg.center.domain.entity;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import java.util.Date;

View File

@ -1,7 +1,7 @@
package cn.axzo.msg.center.domain.entity;
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
import cn.axzo.msg.center.domain.utils.IgnoreEmptyFieldJsonTypeHandler;
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
import cn.axzo.msg.center.service.enums.OrganizationTypeEnum;
import cn.axzo.msg.center.service.enums.PendingMessageStateEnum;
@ -112,13 +112,13 @@ public class Todo extends BaseEntityExt<Todo> {
/**
* 业务扩展参数
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private JSONObject bizExtParam;
/**
* 路由参数
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private JSONObject routerParams;
/**
@ -149,7 +149,7 @@ public class Todo extends BaseEntityExt<Todo> {
/**
* 保存额外的数据信息
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private PendingRecordExt recordExt = new PendingRecordExt();
// !! helper

View File

@ -1,7 +1,7 @@
package cn.axzo.msg.center.domain.entity;
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
import cn.axzo.msg.center.domain.utils.IgnoreEmptyFieldJsonTypeHandler;
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
import cn.axzo.msg.center.service.enums.BizCategoryEnum;
import cn.axzo.msg.center.service.enums.BizFinalStateEnum;
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
@ -85,13 +85,13 @@ public class TodoBusiness extends BaseEntityExt<TodoBusiness> {
/**
* 业务扩展参数
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private JSONObject bizExtParam;
/**
* 路由参数
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private JSONObject routerParams;
/**
@ -117,7 +117,7 @@ public class TodoBusiness extends BaseEntityExt<TodoBusiness> {
/**
* 保存额外的数据信息
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private TodoBusinessExt recordExt = new TodoBusinessExt();
@Override

View File

@ -1,7 +1,7 @@
package cn.axzo.msg.center.domain.entity;
import cn.axzo.msg.center.domain.persistence.BaseEntityExt;
import cn.axzo.msg.center.domain.utils.IgnoreEmptyFieldJsonTypeHandler;
import cn.axzo.msg.center.domain.utils.IgnorePropsJsonTypeHandler;
import cn.axzo.msg.center.service.enums.TodoLogType;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
@ -57,13 +57,13 @@ public class TodoLog extends BaseEntityExt<TodoLog> {
/**
* 关键变化
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private JSONObject logContent;
/**
* 额外信息
*/
@TableField(typeHandler = IgnoreEmptyFieldJsonTypeHandler.class)
@TableField(typeHandler = IgnorePropsJsonTypeHandler.class)
private JSONObject recordExt;
/**

View File

@ -16,7 +16,7 @@ import org.apache.ibatis.type.MappedTypes;
@MappedTypes({Object.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
@RequiredArgsConstructor
public class IgnoreEmptyFieldJsonTypeHandler extends AbstractJsonTypeHandler<Object> {
public class IgnorePropsJsonTypeHandler extends AbstractJsonTypeHandler<Object> {
private final Class<?> type;