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

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

/**
 * HTML预览策略实现
 * 直接返回HTML内容用于前端预览
 *
 * @author hwc
 */
@Component("docTemplateHtmlPreviewTemplateStrategy")
@Slf4j
public class HtmlPreviewTemplateStrategyDocTemplate extends DocTemplateAbstractExportStrategy {

    @Override
    protected Object doExport(String htmlContent, String fileName) {
        log.debug("HTML预览，内容长度: {}", htmlContent.length());

        // 直接返回HTML内容
        HtmlPreviewResult result = HtmlPreviewResult.builder()
                .htmlContent(htmlContent)
                .fileName(fileName)
                .build();

        log.debug("HTML预览完成");
        return result;
    }

    @Override
    protected String getFileExtension() {
        return ".html";
    }

    @Override
    public ExportType getExportType() {
        return ExportType.HTML_PREVIEW;
    }
}