package com.eco.common.mapper.annotation;

import com.eco.common.mapper.core.handler.FieldMapperHandler;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @Description: FieldMapper 字段映射注解
 * @Author: GaoKun Wang
 * @Date: 2024/7/1
 */
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@Documented
@JacksonAnnotationsInside
@JsonSerialize(using = FieldMapperHandler.class)
public @interface FieldMapper {
    /**
     * 类型 (需与实现类上的 {@link FieldMapperType} 注解type对应)
     * 默认取当前字段的值 如果设置了 @{@link FieldMapper#mapper()} 则取映射字段的值
     */
    String type();

    /**
     * 映射字段 (如果不为空则取此字段的值)
     */
    String mapper() default "";

    /**
     * 其他条件 例如: 字典type(sys_user_gender)
     */
    String other() default "";
}
