From 5bfb2dae1356ab9de027f107c50483d8c57d53c4 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期二, 17 八月 2021 11:43:14 +0800
Subject: [PATCH] update 优化OSS异常判断
---
ruoyi-ui/src/utils/download.js | 8 +++++---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java | 5 +++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java
index 609d41f..c7772ab 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java
@@ -2,6 +2,7 @@
import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.annotation.Log;
@@ -78,7 +79,7 @@
@RepeatSubmit
@PostMapping("/upload")
public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
- if (file.isEmpty()) {
+ if (ObjectUtil.isNull(file)) {
throw new ServiceException("涓婁紶鏂囦欢涓嶈兘涓虹┖");
}
SysOss oss = iSysOssService.upload(file);
@@ -93,7 +94,7 @@
@GetMapping("/download/{ossId}")
public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
SysOss sysOss = iSysOssService.getById(ossId);
- if (sysOss == null) {
+ if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("鏂囦欢鏁版嵁涓嶅瓨鍦�!");
}
response.reset();
diff --git a/ruoyi-ui/src/utils/download.js b/ruoyi-ui/src/utils/download.js
index aeac6b5..8f66c24 100644
--- a/ruoyi-ui/src/utils/download.js
+++ b/ruoyi-ui/src/utils/download.js
@@ -42,9 +42,11 @@
if (value !== null && typeof(value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
- let params = propName + '[' + key + ']';
- var subPart = encodeURIComponent(params) + "=";
- urlparams += subPart + encodeURIComponent(value[key]) + "&";
+ if (value[key] !== null && typeof (value[key]) !== 'undefined') {
+ let params = propName + '[' + key + ']';
+ let subPart = encodeURIComponent(params) + "="
+ urlparams += subPart + encodeURIComponent(value[key]) + "&";
+ }
}
} else {
urlparams += part + encodeURIComponent(value) + "&";
--
Gitblit v1.9.3