com.houkunlin.system.dict.starter.jackson.DictDefaultSerializerProviderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of system-dict-starter Show documentation
Show all versions of system-dict-starter Show documentation
系统数据字典自动翻译成字典文本。可集合系统数据库中存储的用户数据字典,也可使用枚举做系统数据字典,主要用在返回数据给前端时自动把字典值翻译成字典文本信息;
The system data dictionary is automatically translated into dictionary text.
The user data dictionary stored in the system database can be aggregated, and the enumeration can also be used as the system data dictionary.
It is mainly used to automatically translate dictionary values into dictionary text information when returning data to the front end.
The newest version!
package com.houkunlin.system.dict.starter.jackson;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
import com.fasterxml.jackson.databind.ser.SerializerFactory;
import com.houkunlin.system.dict.starter.json.DictTextJsonSerializer;
/**
* 自定义 SerializerProvider ,主要是为了处理数据字典的 null 值处理问题
*
* @author HouKunLin
* @since 1.4.3
*/
public class DictDefaultSerializerProviderImpl extends DefaultSerializerProvider {
public DictDefaultSerializerProviderImpl() {
}
public DictDefaultSerializerProviderImpl(final SerializerProvider src, final SerializationConfig config, final SerializerFactory f) {
super(src, config, f);
}
public DictDefaultSerializerProviderImpl(final DefaultSerializerProvider src) {
super(src);
}
@Override
public DefaultSerializerProvider createInstance(final SerializationConfig config, final SerializerFactory jsf) {
return new DictDefaultSerializerProviderImpl(this, config, jsf);
}
/**
* 重写此方法,为了给使用了 {@link com.houkunlin.system.dict.starter.json.DictText} 注解的字段自定义的 null 值序列化器
*
* @param property BeanProperty
* @return JsonSerializer
* @throws JsonMappingException 异常
*/
@Override
public JsonSerializer