管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-24 224591306e6bdcc0051787e759ef0c082757a30a
src/main/java/com/lf/server/controller/show/ExportController.java
@@ -1,6 +1,6 @@
package com.lf.server.controller.show;
import com.lf.server.aspect.SysLog;
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.HttpStatus;
import com.lf.server.entity.all.ResponseMsg;
@@ -112,28 +112,26 @@
    @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
    public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, "用户未登录"));
            if (StringHelper.isEmpty(guid)) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "找不到文件ID", res);
                return;
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (de == null) {
                WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.NOT_FOUND, "文件不存在"));
            if (null == de) {
                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
            de.setDcount(de.getDcount() + 1);
            de.setDownloadUser(ue.getId());
            int rows = downloadService.update(de);
            String filePath = exportService.getDownloadFilePath(de);
            String filePath = downloadService.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);
            }
            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }
    }
}