package com.qmth.teachcloud.mark.enums;

/**
 * 所有管理的文件类型
 */
public enum FileType {

    SHEET("原图", "%d/answer/%d/%s/%s/%d-%d.%s"),
//    SLICE("裁切图", "%d/answer/%d/%s/%d-%d-%d.%s"),
//    PACKAGE("签到表", "%d/card/package.%s"),
    CARD("题卡", "%d/card/answer/%d.%s"),
//    ADMIN_SLICE("管理员上传裁切图", "%d/upload/%s/%d-%d-%d/%s.%s"),
//    ADMIN_SHEET("管理员上传裁原图", "%d/upload/%s/%d-%d/%s.%s"),
    ADAPTE_FILE("适配题卡", "%d/card/answer/%d/%s.%s"),
    ;

    private String name;

    private String pattern;

    private FileType(String name, String pattern) {
        this.name = name;
        this.pattern = pattern;
    }

    public String getName() {
        return name;
    }

    public String getPattern() {
        return pattern;
    }

    public boolean equals(String type) {
        return toString().equalsIgnoreCase(type);
    }

    public static FileType findByText(String text) {
        for (FileType type : values()) {
            if (type.equals(text)) {
                return type;
            }
        }
        return null;
    }

    public String getPath(Object... param) {
        return String.format(pattern, param);
    }

}
