From d452ddf5f00f9f7f7a8de12c02adb725f4be2f12 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期二, 21 四月 2020 16:00:06 +0800
Subject: [PATCH] 用户管理角色选择权限控制

---
 ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java b/ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java
index 3bb81d0..b59fb29 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java
@@ -9,6 +9,7 @@
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
+import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.file.FileUtils;
@@ -86,4 +87,23 @@
             return AjaxResult.error(e.getMessage());
         }
     }
+
+    /**
+     * 鏈湴璧勬簮閫氱敤涓嬭浇
+     */
+    @GetMapping("/common/download/resource")
+    public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception
+    {
+        // 鏈湴璧勬簮璺緞
+        String localPath = RuoYiConfig.getProfile();
+        // 鏁版嵁搴撹祫婧愬湴鍧�
+        String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX);
+        // 涓嬭浇鍚嶇О
+        String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("multipart/form-data");
+        response.setHeader("Content-Disposition",
+                "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
+        FileUtils.writeBytes(downloadPath, response.getOutputStream());
+    }
 }

--
Gitblit v1.9.3