You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.2 KiB
60 lines
2.2 KiB
3 years ago
|
/*
|
||
|
* Copyright (C), 2018-2022
|
||
|
* Project: starter
|
||
|
* FileName: WordExportExtension
|
||
|
* Author: Louis
|
||
|
* Date: 2022/2/23 15:17
|
||
|
*/
|
||
|
package com.fr.plugin.ifhd.provider;
|
||
|
|
||
|
import com.fanruan.api.log.LogKit;
|
||
|
import com.fr.intelli.record.Focus;
|
||
|
import com.fr.intelli.record.Original;
|
||
|
import com.fr.io.collection.ExportCollection;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.plugin.ifhd.export.WordOperate;
|
||
|
import com.fr.record.analyzer.EnableMetrics;
|
||
|
import com.fr.stable.fun.Authorize;
|
||
|
import com.fr.web.core.ReportSessionIDInfor;
|
||
|
import com.fr.web.core.reserve.DefaultExportExtension;
|
||
|
import com.fr.web.core.reserve.Operate;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
import static com.fr.plugin.ifhd.LocaleFinder.PLUGIN_ID;
|
||
|
|
||
|
/**
|
||
|
* <Function Description><br>
|
||
|
* <WordExportExtension>
|
||
|
*
|
||
|
* @author Louis
|
||
|
* @since 1.0.0
|
||
|
*/
|
||
|
@EnableMetrics
|
||
|
@Authorize(callSignKey = PLUGIN_ID)
|
||
|
public class WordExportExtension extends DefaultExportExtension {
|
||
|
private static final String FORMAT_WORD = "word";
|
||
|
|
||
|
private static final Map<String, Operate> OPERATE_MAP;
|
||
|
|
||
|
static {
|
||
|
OPERATE_MAP = new HashMap<String, Operate>();
|
||
|
// 导出类型参考com.fr.web.core.reserve.ExportFactory
|
||
|
OPERATE_MAP.put(FORMAT_WORD, new WordOperate());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@Focus(id = PLUGIN_ID, text = "Plugin-ifhd", source = Original.PLUGIN)
|
||
|
public ExportCollection createCollection(HttpServletRequest req, HttpServletResponse res, ReportSessionIDInfor reportSessionIDInfor, String format, String fileName, boolean isEmbed) throws Exception {
|
||
|
LogKit.info("ifhd-WordExportExtension-createCollection-format:{}", format);
|
||
|
Operate operate = OPERATE_MAP.get(format.toLowerCase());
|
||
|
if (operate != null && PluginContexts.currentContext().isAvailable()) {
|
||
|
operate.setContent(req, res, reportSessionIDInfor, fileName, isEmbed);
|
||
|
return operate.newExportCollection(req, res, reportSessionIDInfor, fileName);
|
||
|
}
|
||
|
return super.createCollection(req, res, reportSessionIDInfor, format, fileName, isEmbed);
|
||
|
}
|
||
|
}
|