Commit ef174668 authored by yanzg's avatar yanzg

下载视频

parent 40fdd28c
...@@ -7,7 +7,7 @@ import com.yanzuoguang.db.impl.DbRow; ...@@ -7,7 +7,7 @@ import com.yanzuoguang.db.impl.DbRow;
* *
* @author 颜佐光 * @author 颜佐光
*/ */
public interface ExcelDaoFinish<T extends Object, M extends Object> extends ExcelDaoStatus<T, M> { public interface ExcelDaoFinish<T extends Object, M extends Object> extends ExcelDao<T, M> {
/** /**
* 循环处理每行数据 * 循环处理每行数据
......
package com.yanzuoguang.cloud.excel;
import com.yanzuoguang.db.impl.DbRow;
import com.yanzuoguang.excel.ExcelStatus;
/**
* Excel导出接口
*
* @author 颜佐光
*/
public interface ExcelDaoStatus<T extends Object, M extends Object> extends ExcelStatus<T> {
/**
* 循环处理每行数据
*
* @param excel excel对象
* @param cond 条件参数
*/
void export(DbRow<M> excel, T cond);
}
...@@ -79,7 +79,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -79,7 +79,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param req 请求对接 * @param req 请求对接
* @param excelDao dao层实现接口 * @param excelDao dao层实现接口
*/ */
public static <T extends Object, M extends Object> ExcelHttp<M> export(ExportBase<T> req, ExcelDao<T, M> excelDao) { public static <T extends Object, M extends Object> ExcelHttp<M> export(ExportBase<T> req, ExcelDao<T, M> excelDao, ExcelStatus<M> excelStatus) {
ExportData config = req.getConfig(); ExportData config = req.getConfig();
if (config == null) { if (config == null) {
throw YzgError.getRuntimeException("024"); throw YzgError.getRuntimeException("024");
...@@ -95,12 +95,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -95,12 +95,7 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
config.setDownFileName(String.format("%s-%s.xlsx", config.getTitle(), config.getSubTitle())); config.setDownFileName(String.format("%s-%s.xlsx", config.getTitle(), config.getSubTitle()));
} }
ExcelHttp<M> excel = null; ExcelHttp<M> excel = new ExcelHttp<>(config, excelStatus);
if (excelDao instanceof ExcelStatus) {
excel = new ExcelHttp<>(config, (ExcelStatus<M>) excelDao);
} else {
excel = new ExcelHttp<>(config, null);
}
// 普通模式生成文件并下载 // 普通模式生成文件并下载
releaseExcel(req, excelDao, excel); releaseExcel(req, excelDao, excel);
...@@ -115,7 +110,19 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -115,7 +110,19 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param excelDao dao层实现接口 * @param excelDao dao层实现接口
*/ */
public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) { public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao) {
ExcelHttp<M> excel = export(req, excelDao); export(req, response, excelDao, null);
}
/**
* 导出数据
*
* @param req 请求对接
* @param response 输出结果
* @param excelDao dao层实现接口
* @param excelStatus excel状态实现
*/
public static <T extends Object, M extends Object> void export(ExportBase<T> req, HttpServletResponse response, ExcelDao<T, M> excelDao, ExcelStatus<M> excelStatus) {
ExcelHttp<M> excel = export(req, excelDao, excelStatus);
try { try {
// 等待下载模式,下载文件 // 等待下载模式,下载文件
excel.down(response); excel.down(response);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment