管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-23 5feada6313b03dc13b348351807a4e29f8d2efd3
src/main/java/com/lf/server/controller/show/ExportController.java
@@ -112,15 +112,15 @@
    @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
    public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                writeInfo(HttpStatus.UNAUTHORIZED, "用户未登录", res);
            if (StringHelper.isEmpty(guid)) {
                WebHelper.writeInfo(HttpStatus.UNAUTHORIZED, "找不到文件ID", res);
                return;
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (de == null) {
                writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
            if (null == de) {
                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
@@ -131,15 +131,7 @@
            String filePath = exportService.getDownloadFilePath(de);
            WebHelper.download(filePath, de.getName(), res);
        } catch (Exception ex) {
            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);
            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }
    }
}