package com.zt.plat.module.base.service.doctemplate.render.export;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;

/**
 * 文档模板导出策略工厂（工厂模式）
 *
 * @author hwc
 */
@Component
@Slf4j
public class DocTemplateExportStrategyFactory {

    @Resource(name = "docTemplateWordExportTemplateStrategy")
    private IExportStrategy wordExportStrategy;

    @Resource(name = "docTemplateHtmlPreviewTemplateStrategy")
    private IExportStrategy htmlPreviewStrategy;

    // TODO: 添加其他导出策略的注入
    // @Resource(name = "docTemplateExcelExportTemplateStrategy")
    // private IExportStrategy excelExportStrategy;
    //
    // @Resource(name = "docTemplatePdfExportTemplateStrategy")
    // private IExportStrategy pdfExportStrategy;

    /**
     * 创建导出方式策略
     *
     * @param exportType 导出类型
     * @return 导出策略实例
     */
    public IExportStrategy createStrategy(ExportType exportType) {
        log.debug("创建导出策略，类型: {}", exportType);

        switch (exportType) {
            case WORD:
                return wordExportStrategy;

            case EXCEL:
                // TODO: 实现Excel导出策略
                throw new UnsupportedOperationException("Excel导出功能尚未实现");

            case PDF:
                // TODO: 实现PDF导出策略
                throw new UnsupportedOperationException("PDF导出功能尚未实现");

            case HTML_PREVIEW:
                return htmlPreviewStrategy;

            default:
                throw new IllegalArgumentException("不支持的导出方式: " + exportType);
        }
    }
}