新增jar中资源加载方法
This commit is contained in:
parent
0072ffe423
commit
159deb799b
@ -1,5 +1,6 @@
|
||||
package ink.wgink.util;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
@ -26,6 +27,18 @@ public class ResourceUtil {
|
||||
return resourceLoader.getResource(resourcePath).getInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* jar资源输入流
|
||||
*
|
||||
* @param resourcePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static InputStream getJarResourceInputStream(String resourcePath) throws IOException {
|
||||
ClassPathResource classPathResource = new ClassPathResource(resourcePath);
|
||||
return classPathResource.getInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源文件
|
||||
*
|
||||
|
@ -6,10 +6,7 @@ import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
@ -21,6 +18,29 @@ import java.net.URLEncoder;
|
||||
*/
|
||||
public class StaticResourceRequestUtil {
|
||||
|
||||
public static void download(HttpServletResponse response, InputStream inputStream, String outFileName) throws IOException {
|
||||
if (StringUtils.isBlank(outFileName)) {
|
||||
throw new ParamsException("文件不能名为空");
|
||||
}
|
||||
String[] fileNameArray = outFileName.split("\\.");
|
||||
if (fileNameArray.length < 1) {
|
||||
throw new ParamsException("文件无后缀名");
|
||||
}
|
||||
try (OutputStream outputStream = response.getOutputStream()) {
|
||||
// response.setHeader("Content-Length", String.valueOf(outFile.length()));
|
||||
response.setContentType(getContentType(fileNameArray[fileNameArray.length - 1]));
|
||||
response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(outFileName, "UTF-8"));
|
||||
response.setHeader("Expires", DateTime.now().plusDays(7).toDateTime(DateTimeZone.forID("GMT")).toString());
|
||||
// 一小时之内不发送新请求
|
||||
response.setHeader("max-age", "3600");
|
||||
byte[] buf = new byte[1024];
|
||||
for (int readLength; (readLength = inputStream.read(buf)) > 0; ) {
|
||||
outputStream.write(buf, 0, readLength);
|
||||
}
|
||||
outputStream.flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载静态资源
|
||||
*
|
||||
@ -39,20 +59,8 @@ public class StaticResourceRequestUtil {
|
||||
if (fileNameArray.length < 1) {
|
||||
throw new ParamsException("文件无后缀名");
|
||||
}
|
||||
try (FileInputStream fileInputStream = new FileInputStream(outFile);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
response.setHeader("Content-Length", String.valueOf(outFile.length()));
|
||||
response.setContentType(getContentType(fileNameArray[fileNameArray.length - 1]));
|
||||
response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(outFileName, "UTF-8"));
|
||||
response.setHeader("Expires", DateTime.now().plusDays(7).toDateTime(DateTimeZone.forID("GMT")).toString());
|
||||
// 一小时之内不发送新请求
|
||||
response.setHeader("max-age", "3600");
|
||||
byte[] buf = new byte[1024];
|
||||
for (int readLength; (readLength = fileInputStream.read(buf)) > 0; ) {
|
||||
outputStream.write(buf, 0, readLength);
|
||||
}
|
||||
outputStream.flush();
|
||||
}
|
||||
FileInputStream fileInputStream = new FileInputStream(outFile);
|
||||
download(response, fileInputStream, outFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,8 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* diagram静态资源
|
||||
@ -34,38 +34,38 @@ public class ActivitiDiagramViewerStaticController {
|
||||
|
||||
@GetMapping("{fileName}")
|
||||
public void root(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/diagram-viewer/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/diagram-viewer/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("images/{fileName}")
|
||||
public void viewerImages(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/diagram-viewer/images/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/diagram-viewer/images/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("images/deployer/{fileName}")
|
||||
public void imagesDeployer(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/diagram-viewer/images/deployer/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/diagram-viewer/images/deployer/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("images/deployer/blue/{fileName}")
|
||||
public void imagesDeployerBlue(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/diagram-viewer/images/deployer/blue/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/diagram-viewer/images/deployer/blue/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("js/{fileName}")
|
||||
public void js(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/diagram-viewer/js/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/diagram-viewer/js/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("js/jquery/{fileName}")
|
||||
public void jsJquery(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/diagram-viewer/js/jquery/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/diagram-viewer/js/jquery/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 用于汉化在线编辑器
|
||||
@ -34,122 +34,122 @@ public class ActivitiEditorAppStaticController {
|
||||
|
||||
@GetMapping("{fileName}")
|
||||
public void root(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("configuration/{fileName}")
|
||||
public void configuration(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/configuration/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/configuration/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("configuration/properties/{fileName}")
|
||||
public void diagramViewerImagesDeployer(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/configuration/properties/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/configuration/properties/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("css/{fileName}")
|
||||
public void css(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/css/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/css/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("editor/{fileName}")
|
||||
public void editor(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/editor/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/editor/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("editor/{folder}/{fileName}")
|
||||
public void editor(HttpServletResponse httpServletResponse, @PathVariable("folder") String folder, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/editor/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/editor/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("fonts/{fileName}")
|
||||
public void fonts(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/fonts/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/fonts/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("i18n/{fileName}")
|
||||
public void i18n(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/i18n/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/i18n/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("images/{fileName}")
|
||||
public void images(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/images/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/images/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("libs/{fileName}")
|
||||
public void libs(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/libs/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/libs/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("libs/{folder}/{fileName}")
|
||||
public void libs(HttpServletResponse httpServletResponse, @PathVariable("folder") String folder, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/libs/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/libs/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("libs/bootstrap_3.1.1/{folder}/{fileName}")
|
||||
public void libsBootstrap(HttpServletResponse httpServletResponse, @PathVariable("folder") String folder, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/libs/bootstrap_3.1.1/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/libs/bootstrap_3.1.1/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("libs/es5-shim-15.3.4.5/tests/{fileName}")
|
||||
public void libSes5ShimTests(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/libs/es5-shim-15.3.4.5/tests" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/libs/es5-shim-15.3.4.5/tests" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("libs/es5-shim-15.3.4.5/tests/{floder}/{fileName}")
|
||||
public void libSes5ShimTests(HttpServletResponse httpServletResponse, @PathVariable("folder") String folder, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/libs/es5-shim-15.3.4.5/tests/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/libs/es5-shim-15.3.4.5/tests/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("libs/json3_3.2.6/lib/{fileName}")
|
||||
public void libJsonLib(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/libs/json3_3.2.6/lib/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/libs/json3_3.2.6/lib/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("partials/{fileName}")
|
||||
public void partials(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/partials/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/partials/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("popups/{fileName}")
|
||||
public void popups(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/popups/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/popups/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("stencilsets/bpmn2.0/icons/{fileName}")
|
||||
public void stencilsetsBpmnIcons(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/stencilsets/bpmn2.0/icons/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/stencilsets/bpmn2.0/icons/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("stencilsets/bpmn2.0/icons/{folder}/{fileName}")
|
||||
public void stencilsetsBpmnIcons(HttpServletResponse httpServletResponse, @PathVariable("folder") String folder, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/stencilsets/bpmn2.0/icons/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/stencilsets/bpmn2.0/icons/" + folder + "/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("stencilsets/bpmn2.0/icons/activity/list/{fileName}")
|
||||
public void stencilsetsBpmnIconsActivitiList(HttpServletResponse httpServletResponse, @PathVariable("fileName") String fileName) throws IOException {
|
||||
File file = ResourceUtil.getResourceFile("static/editor-app/stencilsets/bpmn2.0/icons/activity/list/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, file, fileName);
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("static/editor-app/stencilsets/bpmn2.0/icons/activity/list/" + fileName);
|
||||
StaticResourceRequestUtil.download(httpServletResponse, inputStream, fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import org.activiti.image.impl.DefaultProcessDiagramGenerator;
|
||||
import org.apache.batik.transcoder.TranscoderInput;
|
||||
import org.apache.batik.transcoder.TranscoderOutput;
|
||||
import org.apache.batik.transcoder.image.PNGTranscoder;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -25,6 +24,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -98,9 +98,14 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
|
||||
|
||||
@Override
|
||||
public JSONObject getStencilset() throws IOException {
|
||||
FileInputStream fileInputStream = new FileInputStream(ResourceUtil.getResourceFile("static/stencilset.json"));
|
||||
String result = IOUtils.toString(fileInputStream, ISystemConstant.CHARSET_UTF8);
|
||||
return JSONObject.parseObject(result);
|
||||
String content;
|
||||
try (InputStream jarResourceInputStream = ResourceUtil.getJarResourceInputStream("static/stencilset.json");
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(jarResourceInputStream));) {
|
||||
content = bufferedReader.lines().collect(Collectors.joining("\n"));
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
return JSONObject.parseObject(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,7 +3,7 @@ package ink.wgink.service.user.controller.route;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.user.IUserExpandBaseService;
|
||||
import ink.wgink.util.ResourceUtil;
|
||||
import ink.wgink.util.request.RequestUtil;
|
||||
import ink.wgink.util.request.StaticResourceRequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -12,8 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -79,8 +79,8 @@ public class UserRouteController {
|
||||
|
||||
@GetMapping("upload/upload-excel-template")
|
||||
public void excelTemplate(HttpServletResponse response) throws IOException {
|
||||
File template = ResourceUtil.getResourceFile("templates/user/upload/upload-excel-template.xls");
|
||||
RequestUtil.download(response, template, "用户导入模板.xls");
|
||||
InputStream inputStream = ResourceUtil.getJarResourceInputStream("templates/user/upload/upload-excel-template.xls");
|
||||
StaticResourceRequestUtil.download(response, inputStream, "upload-excel-template.xls");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user