From 4ec6b4b2f09d573d303940d453187c21e407e6ee Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期四, 06 四月 2023 12:28:04 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/controller/show/ApplyController.java |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/show/ApplyController.java b/src/main/java/com/lf/server/controller/show/ApplyController.java
index 9894232..b39f129 100644
--- a/src/main/java/com/lf/server/controller/show/ApplyController.java
+++ b/src/main/java/com/lf/server/controller/show/ApplyController.java
@@ -2,17 +2,21 @@
 
 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;
 import com.lf.server.entity.all.StaticData;
 import com.lf.server.entity.ctrl.DownloadReqEntity;
+import com.lf.server.entity.data.DownloadEntity;
 import com.lf.server.entity.show.ApplyEntity;
 import com.lf.server.entity.show.FlowEntity;
 import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.helper.AesHelper;
 import com.lf.server.helper.StringHelper;
+import com.lf.server.helper.WebHelper;
 import com.lf.server.service.data.DownloadService;
 import com.lf.server.service.show.ApplyService;
 import com.lf.server.service.show.FlowService;
+import com.lf.server.service.sys.DownlogService;
 import com.lf.server.service.sys.TokenService;
 import com.lf.server.service.sys.UserService;
 import io.swagger.annotations.Api;
@@ -23,6 +27,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.sql.Timestamp;
 import java.util.List;
 
@@ -45,6 +50,12 @@
 
     @Autowired
     UserService userService;
+
+    @Autowired
+    DownlogService downlogService;
+
+    @Autowired
+    DownloadService downloadService;
 
     @SysLog()
     @ApiOperation(value = "鎻掑叆鏁版嵁鐢宠")
@@ -266,4 +277,29 @@
             return fail(ex, null);
         }
     }
+
+    @SysLog()
+    @ApiOperation(value = "涓嬭浇鏂囦欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "guid", value = "鏂囦欢GUID", dataType = "String", paramType = "query")
+    })
+    @ResponseBody
+    @GetMapping(value = "/downloadFile")
+    public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            DownloadEntity de = downloadService.selectByGuid(guid);
+            if (null == de) {
+                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "鏂囦欢涓嶅瓨鍦�", res);
+                return;
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            downlogService.updateInfos(ue, de, req);
+
+            String filePath = downloadService.getDownloadFilePath(de);
+            WebHelper.download(filePath, de.getName(), res);
+        } catch (Exception ex) {
+            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
+        }
+    }
 }

--
Gitblit v1.9.3