diff --git a/hchyun-ui/src/api/system/download.js b/hchyun-ui/src/api/system/download.js index c5a6040..91e19ba 100644 --- a/hchyun-ui/src/api/system/download.js +++ b/hchyun-ui/src/api/system/download.js @@ -1,14 +1,12 @@ import axios from "axios"; import {getToken} from "@/utils/auth"; -export function downloadFile(fileId){ - axios({ - method:'get', - url:process.env.VUE_APP_BASE_API+'/system/file/download/'+fileId, - headers:{ - token:'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - } - }).then(res=>{ - return res; - }) +export function downloadFile(fileId) { + return axios({ + method: 'get', + url: process.env.VUE_APP_BASE_API + '/system/file/download/' + fileId, + headers: { + token: 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + } + }) } diff --git a/hchyun-ui/src/views/system/file/index.vue b/hchyun-ui/src/views/system/file/index.vue index 29d356f..08fe9e3 100644 --- a/hchyun-ui/src/views/system/file/index.vue +++ b/hchyun-ui/src/views/system/file/index.vue @@ -342,10 +342,9 @@ export default { cancelButtonText: "取消", type: "warning" }).then(function (){ - return downloadFile(row.fileId) + return downloadFile(row.fileId) }).then(res =>{ - console.log(res) - // this.download(data.msg); + this.download(res.data.msg); }) }, // 表单重置 diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java index 08113e9..59875c9 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/controller/common/CommonController.java @@ -39,9 +39,9 @@ public class CommonController { @GetMapping("common/download") public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { try { - if (!FileUtils.isValidFilename(fileName)) { - throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 " , fileName)); - } +// if (!FileUtils.isValidFilename(fileName)) { +// throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 " , fileName)); +// } String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); String filePath = HchYunConfig.getDownloadPath() + fileName; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUtils.java index 1067a1c..162638b 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/file/FileUtils.java @@ -68,6 +68,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils { File file = new File(filePath); // 路径为文件且不为空则进行删除 if (file.isFile() && file.exists()) { + System.gc(); file.delete(); flag = true; } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/impl/SameUrlDataInterceptor.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/impl/SameUrlDataInterceptor.java index 5e3ff88..2219808 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -18,12 +19,11 @@ import com.hchyun.framework.interceptor.RepeatSubmitInterceptor; /** * 判断请求url和数据是否和上一次相同, * 如果和上次相同,则是重复提交表单。 有效时间为10秒内。 - * + * * @author hchyun */ @Component -public class SameUrlDataInterceptor extends RepeatSubmitInterceptor -{ +public class SameUrlDataInterceptor extends RepeatSubmitInterceptor { public final String REPEAT_PARAMS = "repeatParams"; public final String REPEAT_TIME = "repeatTime"; @@ -37,30 +37,26 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor /** * 间隔时间,单位:秒 默认10秒 - * + *
* 两次相同参数的请求,如果间隔时间大于该参数,系统不会认定为重复提交的数据
*/
private int intervalTime = 10;
- public void setIntervalTime(int intervalTime)
- {
+ public void setIntervalTime(int intervalTime) {
this.intervalTime = intervalTime;
}
@SuppressWarnings("unchecked")
@Override
- public boolean isRepeatSubmit(HttpServletRequest request)
- {
+ public boolean isRepeatSubmit(HttpServletRequest request) {
String nowParams = "";
- if (request instanceof RepeatedlyRequestWrapper)
- {
+ if (request instanceof RepeatedlyRequestWrapper) {
RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
nowParams = HttpHelper.getBodyString(repeatedlyRequest);
}
// body参数为空,获取Parameter的数据
- if (StringUtils.isEmpty(nowParams))
- {
+ if (StringUtils.isEmpty(nowParams)) {
nowParams = JSONObject.toJSONString(request.getParameterMap());
}
Map