package com.ruoyi.common.validRule.deviceExist;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 判断设备是否存在
 * @author wjh
 * 2024/6/13
 */
@Documented
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE })
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(DeviceExist.List.class)
@Constraint(validatedBy = { DeviceExistValidator.class })
public @interface DeviceExist {
    String message() default "{*.validation.constraint.Enum.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * 是否允许null值，默认是允许
     */
    boolean allowNull() default true;

    /**
     * 校验是否归属商户
     */
    boolean checkBelong() default false;

    @Documented
    @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE })
    @Retention(RetentionPolicy.RUNTIME)
    @interface List {
        DeviceExist[] value();
    }
}
