remove 移除过期代码

2.X
疯狂的狮子li 2 years ago
parent 1cd4abba4f
commit 12bfe3a9f4

@ -1,29 +0,0 @@
package org.dromara.common.dict.annotation;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.dromara.common.dict.jackson.DictDataJsonSerializer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
*
* @author itino
* @deprecated 使
*/
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@JacksonAnnotationsInside
@JsonSerialize(using = DictDataJsonSerializer.class)
public @interface DictDataMapper {
/**
* type (: sys_user_sex)
*/
String dictType() default "";
}

@ -1,58 +0,0 @@
package org.dromara.common.dict.jackson;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import org.dromara.common.core.service.DictService;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.dict.annotation.DictDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import java.io.IOException;
import java.util.Objects;
/**
* json
*
* @author itino
* @deprecated 使
*/
@Deprecated
@Slf4j
public class DictDataJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {
private String dictType;
@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
try {
DictService dictService = SpringUtils.getBean(DictService.class);
if (ObjectUtil.isNotNull(dictService)) {
String label = dictService.getDictLabel(dictType, value);
gen.writeString(StringUtils.isNotBlank(label) ? label : value);
} else {
gen.writeString(value);
}
} catch (BeansException e) {
log.error("字典数据未查到, 采用默认处理 => {}", e.getMessage());
gen.writeString(value);
}
}
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
DictDataMapper anno = property.getAnnotation(DictDataMapper.class);
if (Objects.nonNull(anno) && StrUtil.isNotBlank(anno.dictType())) {
this.dictType = anno.dictType();
return this;
}
return prov.findValueSerializer(property.getType(), property);
}
}
Loading…
Cancel
Save