package com.tofly.base.em;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;

/**
 * @ClassName: ExcelExportFileTypeEnum
 * @Description: 导出文件枚举
 * @Author Zev
 * @Date 2021/3/25
 * @Version 1.0.0
 */
@Getter
@AllArgsConstructor
public enum ExcelExportFileTypeEnum {
    /**
     *
     */
    EXPORT_USER_ADD("/批量账号创建模板.xlsx","批量账号创建","userService","0"),
    EXPORT_DEPARTMENT_ADD("/批量单位组织创建模板.xlsx","批量单位组织创建模板","departmentService","0"),
    EXPORT_USER_INFO("/userInfo.xlsx","用户导出模板","userService","1"),
    EXPORT_OPERATION_DEPT_RECORD("/operationRecordDept.xlsx","部门操作记录","logService","0"),
    EXPORT_OPERATION_USER_RECORD("/operationRecordUser.xlsx","人员操作记录","logService","1"),
    ;
    /**
     * 导出模板文件
     */
    private String templateFile;
    /**
     * 导出表格名
     */
    private String sheetName;

    /**
     * 模板服务类型
     */
    private String templateServiceType;

    /**
     * 是否为示例模板
     */
    private String flag;

    /**
     * 根据模型类型和是否为示例模板获取对应枚举对象
     *
     * @param templateServiceType 模型类型
     * @param flag                是否为示例模板
     * @return 枚举对象
     */
    public static ExcelExportFileTypeEnum getExcelExportFileTypeEnum(String templateServiceType, String flag) {
        if (StringUtils.isEmpty(templateServiceType)) {
            return null;
        }

        for (ExcelExportFileTypeEnum e : ExcelExportFileTypeEnum.values()) {
            if (e.templateServiceType.equalsIgnoreCase(templateServiceType) && e.flag.equalsIgnoreCase(flag)) {
                return e;
            }
        }
        return null;
    }
}
