Search in sources :

Example 1 with ExportExceptions

use of com.hb0730.boot.admin.exceptions.ExportExceptions in project boot-admin by hb0730.

the class PostController method export.

/**
 * 导出
 *
 * @param response 响应
 * @param params   请求参数,用于导出过滤
 * @throws ExportExceptions 导出异常
 */
@Override
@PostMapping("/export")
@Log(value = "导出", paramsName = { "params" }, businessType = BusinessTypeEnum.EXPORT)
@PreAuthorize("hasAnyAuthority('ROLE_ADMINISTRATOR','post:export')")
public void export(HttpServletResponse response, @RequestBody PostParams params) throws ExportExceptions {
    List<PostExcelDTO> export = service.export(params);
    HashMap<String, Object> map = Maps.newHashMap();
    try {
        map.put(ExcelConstant.FILE_NAME, "post_excel");
        map.put(ExcelConstant.DATA_LIST, export);
        ExcelUtils.writeWeb(response, map, ExcelTypeEnum.XLS, PostExcelDTO.class);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ExportExceptions("岗位导出失败", e);
    }
}
Also used : PostExcelDTO(com.hb0730.boot.admin.project.system.post.model.dto.PostExcelDTO) ExportExceptions(com.hb0730.boot.admin.exceptions.ExportExceptions) IOException(java.io.IOException) PostMapping(org.springframework.web.bind.annotation.PostMapping) Log(com.hb0730.boot.admin.annotation.Log) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

Log (com.hb0730.boot.admin.annotation.Log)1 ExportExceptions (com.hb0730.boot.admin.exceptions.ExportExceptions)1 PostExcelDTO (com.hb0730.boot.admin.project.system.post.model.dto.PostExcelDTO)1 IOException (java.io.IOException)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1