管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-23 298a420d8fa2435e2ca2fd7f4afa47118695f6bf
src/main/java/com/lf/server/controller/show/ExportController.java
@@ -114,12 +114,14 @@
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, "用户未登录"));
                writeInfo(HttpStatus.UNAUTHORIZED, "用户未登录", res);
                return;
            }
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (de == null) {
                WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.NOT_FOUND, "文件不存在"));
                writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
            de.setDcount(de.getDcount() + 1);
@@ -129,11 +131,15 @@
            String filePath = exportService.getDownloadFilePath(de);
            WebHelper.download(filePath, de.getName(), res);
        } catch (Exception ex) {
            try {
                WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, ex.getMessage()));
            } catch (Exception e) {
                log.error(e.getMessage(), e);
            }
            writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }
    }
    private void writeInfo(HttpStatus status, String info, HttpServletResponse res) {
        try {
            WebHelper.write2Page(res, WebHelper.getErrJson(status, info));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}