|
@@ -3,12 +3,20 @@ package com.zjugis.business.controller;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zjugis.business.bean.dto.LoanDto;
|
|
|
import com.zjugis.business.bean.entity.Loan;
|
|
|
+import com.zjugis.business.bean.response.LoanExcelResponse;
|
|
|
import com.zjugis.business.bean.response.LoanRespense;
|
|
|
import com.zjugis.business.service.LoanService;
|
|
|
import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
+import com.zjugis.framework.excel.core.util.ExcelUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -83,5 +91,22 @@ public class LoanController {
|
|
|
public CommonResult<Integer> getCount(LoanDto loan) {
|
|
|
return CommonResult.success(loanService.getCount(loan));
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/loan/exportData")
|
|
|
+ public void export(LoanDto pageReqVO, HttpServletResponse response) throws IOException {
|
|
|
+ List<Loan> projects = loanService.getExportData(pageReqVO);
|
|
|
+
|
|
|
+ List<LoanExcelResponse> excelList = new ArrayList<>(projects.size());
|
|
|
+ projects.forEach(project -> {
|
|
|
+ LoanExcelResponse projectExcelResponse = new LoanExcelResponse();
|
|
|
+ BeanUtils.copyProperties(project,projectExcelResponse);
|
|
|
+ excelList.add(projectExcelResponse);
|
|
|
+ });
|
|
|
+ response.setContentType("multipart/form-data");
|
|
|
+ response.setCharacterEncoding(String.valueOf(StandardCharsets.UTF_8));
|
|
|
+ response.setHeader("Content-Disposition",
|
|
|
+ "attachment;filename*=utf-8'zh-cn'" + URLEncoder.encode("借款查询列表.xlsx", String.valueOf(StandardCharsets.UTF_8)));
|
|
|
+ ExcelUtils.write(response, "借款查询列表.xlsx", "借款查询列表", LoanExcelResponse.class, excelList);
|
|
|
+ }
|
|
|
}
|
|
|
|