package com.crunii.micro.common.annotations;

import com.crunii.micro.common.enums.LimitUploadFileType;

import java.lang.annotation.*;

/**
 * @description 文件校验
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface LimitUploadFileTypeCheck {
    /**
     * 校验不通过提示信息
     *
     * @return
     */
    String message() default "不支持的文件格式";

    /**
     * 校验方式
     */
    CheckType type() default CheckType.SUFFIX;

    /**
     * 支持的文件后缀
     *
     * @return
     */
    String[] supportedSuffixes() default {"ppt", "pptx", "docx", "pdf", "bmp", "jpg", "jpeg", "png", "gif", "zip", "doc", "txt", "xls", "xlsx", "rar", "cad", "dwg", "PPT", "PPTX", "DOCX", "PDF", "BMP", "JPG", "JPEG", "PNG", "GIF", "ZIP", "DOC", "TXT", "XLS", "XLSX", "RAR", "CAD", "DWG"};

    /**
     * 支持的文件类型
     *
     * @return
     */
    LimitUploadFileType[] supportedFileTypes() default {};

    enum CheckType {
        /**
         * 仅校验后缀
         */
        SUFFIX,
        /**
         * 校验文件头(魔数)
         */
        MAGIC_NUMBER,
        /**
         * 同时校验后缀和文件头
         */
        SUFFIX_MAGIC_NUMBER
    }
}
