From 7e80ca95f631ecbce3d7de1b89f62d4f6de6d58f Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 26 十一月 2022 09:54:36 +0800
Subject: [PATCH] q

---
 src/main/java/com/lf/server/controller/show/ExportController.java |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 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..46fec9c 100644
--- a/src/main/java/com/lf/server/controller/show/ExportController.java
+++ b/src/main/java/com/lf/server/controller/show/ExportController.java
@@ -59,11 +59,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,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.BAD_REQUEST, "鎵句笉鍒版枃浠禝D", 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;
             }
 
@@ -128,18 +128,10 @@
             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) {
-            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