class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer
{
    private DesensitizedType desensitizedType;

    @Override
    public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException
    {
        if (desensitization())
        {
            gen.writeString(desensitizedType.desensitizer().apply(value));
        }
        else
        {
            gen.writeString(value);
        }
    }

    @Override
    public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
            throws JsonMappingException
    {<FILL_FUNCTION_BODY>}

    /**
     * 是否需要脱敏处理
     */
    private boolean desensitization()
    {
        try
        {
            LoginUser securityUser = SecurityUtils.getLoginUser();
            // 管理员不脱敏
            return !securityUser.getUser().isAdmin();
        }
        catch (Exception e)
        {
            return true;
        }
    }
}

        Sensitive annotation = property.getAnnotation(Sensitive.class);
        if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass()))
        {
            this.desensitizedType = annotation.desensitizedType();
            return this;
        }
        return prov.findValueSerializer(property.getType(), property);
    
<methods>public void <init>() ,public void acceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.JavaType) throws com.fasterxml.jackson.databind.JsonMappingException,public JsonSerializer<?> getDelegatee() ,public Class<java.lang.String> handledType() ,public boolean isEmpty(java.lang.String) ,public boolean isEmpty(com.fasterxml.jackson.databind.SerializerProvider, java.lang.String) ,public boolean isUnwrappingSerializer() ,public Iterator<com.fasterxml.jackson.databind.ser.PropertyWriter> properties() ,public JsonSerializer<java.lang.String> replaceDelegatee(JsonSerializer<?>) ,public abstract void serialize(java.lang.String, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider) throws java.io.IOException,public void serializeWithType(java.lang.String, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer) throws java.io.IOException,public JsonSerializer<java.lang.String> unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer) ,public boolean usesObjectId() ,public JsonSerializer<?> withFilterId(java.lang.Object) <variables>