package org.springnewfiber.dataadapter.sswj.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.apache.ibatis.annotations.Param; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springnewfiber.dataadapter.sswj.service.impl.ExcelPlusServiceImpl; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * @program: newfiber-data-adapter * @description: * @author: djt * @create: 2022-05-18 13:59 **/ @RestController @AllArgsConstructor @RequestMapping("/ExcelPlus") @Api(value = "导出数据", tags = "导出数据") public class ExcelPlusController { private final ExcelPlusServiceImpl excelPlusService; @RequestMapping("/excelDownload") @ApiOperation(value = "下载excel",produces = "application/octet-stream") public void excelDownload(@ApiParam(value = "库名称")@RequestParam(defaultValue = "swj") String dataBase,@ApiParam(value = "表名", required = true) @RequestParam String tableName, HttpServletResponse response,@ApiParam(value = "sql拼接") @RequestParam(required = false) String lastSql) { try { excelPlusService.exportExcel(dataBase, tableName, response,lastSql); } catch (IOException e) { throw new RuntimeException("文件写入失败"); } } }