mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-12 20:36:50 +08:00
【新需求】案例管理支持当前筛选条件案例列表导出,此处可导出案例数据:浏览量、推荐量、引用量、点赞量、评论量、分享量,收藏量、导出时间、作者
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.xboe.module.boecase.api;
|
package com.xboe.module.boecase.api;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -16,6 +17,7 @@ import com.xboe.module.boecase.vo.CaseExportVo;
|
|||||||
import com.xboe.module.dict.entity.DictItem;
|
import com.xboe.module.dict.entity.DictItem;
|
||||||
import com.xboe.module.excel.ExportsExcelSenderUtil;
|
import com.xboe.module.excel.ExportsExcelSenderUtil;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -139,6 +141,51 @@ public class CasesApi extends ApiBaseController {
|
|||||||
return success(casesPageList);
|
return success(casesPageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出案例数据
|
||||||
|
* */
|
||||||
|
@PostMapping("/exportCase")
|
||||||
|
public void exportCase(Pagination pager, CaseVo caseVo,HttpServletResponse response){
|
||||||
|
OutputStream OutputStream=null;
|
||||||
|
try {
|
||||||
|
OutputStream = response.getOutputStream();
|
||||||
|
LinkedHashMap<String,String> map = new LinkedHashMap<>();
|
||||||
|
map.put("浏览量","views");
|
||||||
|
map.put("推荐量","recommends");
|
||||||
|
map.put("引用量","cites");
|
||||||
|
map.put("点赞量","praises");
|
||||||
|
map.put("评论量","comments");
|
||||||
|
map.put("分享量","shares");
|
||||||
|
map.put("收藏量","favorites");
|
||||||
|
map.put("导出时间","exportDate");
|
||||||
|
map.put("作者","authorName");
|
||||||
|
List<Cases> list = casesService.managerList(pager.getPageIndex(), pager.getPageSize(), caseVo).getList();
|
||||||
|
List<CaseExportVo> exportVos = new ArrayList<>();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
for (Cases c:list){
|
||||||
|
CaseExportVo caseExportVo = new CaseExportVo();
|
||||||
|
caseExportVo.setViews(c.getViews());
|
||||||
|
caseExportVo.setRecommends(c.getRecommends());
|
||||||
|
caseExportVo.setCites(c.getCites());
|
||||||
|
caseExportVo.setPraises(c.getPraises());
|
||||||
|
caseExportVo.setComments(c.getComments());
|
||||||
|
caseExportVo.setShares(c.getShares());
|
||||||
|
caseExportVo.setFavorites(c.getFavorites());
|
||||||
|
caseExportVo.setExportDate(now);
|
||||||
|
caseExportVo.setAuthorName(c.getAuthorName());
|
||||||
|
|
||||||
|
|
||||||
|
exportVos.add(caseExportVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=cases.xlsx");
|
||||||
|
ExportsExcelSenderUtil.export(map,exportVos, OutputStream,"yyyy-MM-dd HH:mm:ss");
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("导出失败",e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出我的案例
|
* 导出我的案例
|
||||||
* */
|
* */
|
||||||
|
|||||||
@@ -8,21 +8,30 @@ import java.time.LocalDateTime;
|
|||||||
@Data
|
@Data
|
||||||
public class CaseExportVo {
|
public class CaseExportVo {
|
||||||
|
|
||||||
|
private Integer views;
|
||||||
|
|
||||||
|
private Integer recommends;
|
||||||
|
|
||||||
|
private Integer cites;
|
||||||
|
|
||||||
|
private Integer praises;
|
||||||
|
|
||||||
|
private Integer comments;
|
||||||
|
|
||||||
|
private Integer shares;
|
||||||
|
|
||||||
|
private Integer favorites;
|
||||||
|
|
||||||
|
private LocalDateTime exportDate;
|
||||||
|
|
||||||
|
private String authorName;
|
||||||
|
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private LocalDateTime endTime;
|
|
||||||
|
|
||||||
private String caseScope;
|
private String caseScope;
|
||||||
|
|
||||||
private Integer views;
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
private Integer praises;
|
|
||||||
|
|
||||||
private Integer shares;
|
|
||||||
|
|
||||||
private Integer favorites;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user