From 17abb629a1921058e1a6ed5562e9d94e74b8dffc Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 23 十二月 2022 18:25:31 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/show/ExportController.java | 34 ++++++++++++++-------------------- 1 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/lf/server/controller/show/ExportController.java b/src/main/java/com/lf/server/controller/show/ExportController.java index 5bf50b2..b74915e 100644 --- a/src/main/java/com/lf/server/controller/show/ExportController.java +++ b/src/main/java/com/lf/server/controller/show/ExportController.java @@ -11,6 +11,7 @@ import com.lf.server.helper.WebHelper; import com.lf.server.service.data.DownloadService; import com.lf.server.service.show.ExportService; +import com.lf.server.service.sys.DownlogService; import com.lf.server.service.sys.TokenService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -38,6 +39,9 @@ ExportService exportService; @Autowired + DownlogService downlogService; + + @Autowired DownloadService downloadService; @SysLog() @@ -59,11 +63,11 @@ return fail("鐢ㄦ埛鏈櫥褰�", null); } - int count = downloadService.selectCountForExport(ue.getCreateUser(), name); + int count = downloadService.selectCountForUser(ue.getCreateUser(), 2, name); if (count == 0) { return success(0, null); } - List<DownloadEntity> rs = downloadService.selectByPageForExport(ue.getCreateUser(), name, pageSize, pageSize * (pageIndex - 1)); + List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getCreateUser(), 2, name, pageSize, pageSize * (pageIndex - 1)); return success(count, rs); } catch (Exception ex) { @@ -112,34 +116,24 @@ @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.BAD_REQUEST, "鎵句笉鍒版枃浠禝D", res); return; } DownloadEntity de = downloadService.selectByGuid(guid); - if (de == null) { - writeInfo(HttpStatus.NOT_FOUND, "鏂囦欢涓嶅瓨鍦�", res); + if (null == de) { + WebHelper.writeInfo(HttpStatus.NOT_FOUND, "鏂囦欢涓嶅瓨鍦�", res); return; } - de.setDcount(de.getDcount() + 1); - de.setDownloadUser(ue.getId()); - int rows = downloadService.update(de); + UserEntity ue = tokenService.getCurrentUser(req); + downlogService.updateInfos(ue, de, req); - String filePath = exportService.getDownloadFilePath(de); + String filePath = downloadService.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); } } } -- Gitblit v1.9.3