From 22b4f87232c9cb1e6f49927c8d0e11ec95f51724 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期二, 28 九月 2021 09:32:56 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java |   44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 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..3c04353 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,8 @@
 
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.http.HttpException;
 import cn.hutool.http.HttpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.annotation.Log;
@@ -9,6 +11,7 @@
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.core.validate.QueryGroup;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.JsonUtils;
@@ -47,7 +50,7 @@
  * @author Lion Li
  */
 @Validated
-@Api(value = "OSS浜戝瓨鍌ㄦ帶鍒跺櫒", tags = {"OSS浜戝瓨鍌ㄧ鐞�"})
+@Api(value = "OSS瀵硅薄瀛樺偍鎺у埗鍣�", tags = {"OSS瀵硅薄瀛樺偍绠$悊"})
 @RequiredArgsConstructor(onConstructor_ = @Autowired)
 @RestController
 @RequestMapping("/system/oss")
@@ -57,28 +60,28 @@
 	private final ISysConfigService iSysConfigService;
 
 	/**
-	 * 鏌ヨOSS浜戝瓨鍌ㄥ垪琛�
+	 * 鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃
 	 */
-	@ApiOperation("鏌ヨOSS浜戝瓨鍌ㄥ垪琛�")
+	@ApiOperation("鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃")
 	@PreAuthorize("@ss.hasPermi('system:oss:list')")
 	@GetMapping("/list")
-	public TableDataInfo<SysOssVo> list(@Validated SysOssBo bo) {
+	public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo) {
 		return iSysOssService.queryPageList(bo);
 	}
 
 	/**
-	 * 涓婁紶OSS浜戝瓨鍌�
+	 * 涓婁紶OSS瀵硅薄瀛樺偍
 	 */
-	@ApiOperation("涓婁紶OSS浜戝瓨鍌�")
+	@ApiOperation("涓婁紶OSS瀵硅薄瀛樺偍")
 	@ApiImplicitParams({
 		@ApiImplicitParam(name = "file", value = "鏂囦欢", dataType = "java.io.File", required = true),
 	})
 	@PreAuthorize("@ss.hasPermi('system:oss:upload')")
-	@Log(title = "OSS浜戝瓨鍌�", businessType = BusinessType.INSERT)
+	@Log(title = "OSS瀵硅薄瀛樺偍", businessType = BusinessType.INSERT)
 	@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);
@@ -88,29 +91,38 @@
 		return AjaxResult.success(map);
 	}
 
-	@ApiOperation("涓嬭浇OSS浜戝瓨鍌�")
+	@ApiOperation("涓嬭浇OSS瀵硅薄瀛樺偍")
 	@PreAuthorize("@ss.hasPermi('system:oss:download')")
 	@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();
 		response.addHeader("Access-Control-Allow-Origin", "*");
 		response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
-		FileUtils.setAttachmentResponseHeader(response, URLEncoder.encode(sysOss.getOriginalName(), StandardCharsets.UTF_8.toString()));
+		FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
 		response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
-		long data = HttpUtil.download(sysOss.getUrl(), response.getOutputStream(), false);
+		long data;
+		try {
+			data = HttpUtil.download(sysOss.getUrl(), response.getOutputStream(), false);
+		} catch (HttpException e) {
+			if (e.getMessage().contains("403")) {
+				throw new ServiceException("鏃犺鍙栨潈闄�, 璇峰湪瀵瑰簲鐨凮SS寮�鍚�'鍏湁璇�'鏉冮檺!");
+			} else {
+				throw new ServiceException(e.getMessage());
+			}
+		}
 		response.setContentLength(Convert.toInt(data));
 	}
 
 	/**
-	 * 鍒犻櫎OSS浜戝瓨鍌�
+	 * 鍒犻櫎OSS瀵硅薄瀛樺偍
 	 */
-	@ApiOperation("鍒犻櫎OSS浜戝瓨鍌�")
+	@ApiOperation("鍒犻櫎OSS瀵硅薄瀛樺偍")
 	@PreAuthorize("@ss.hasPermi('system:oss:remove')")
-	@Log(title = "OSS浜戝瓨鍌�" , businessType = BusinessType.DELETE)
+	@Log(title = "OSS瀵硅薄瀛樺偍" , businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ossIds}")
 	public AjaxResult<Void> remove(@NotEmpty(message = "涓婚敭涓嶈兘涓虹┖")
 								   @PathVariable Long[] ossIds) {
@@ -122,7 +134,7 @@
 	 */
 	@ApiOperation("鍙樻洿鍥剧墖鍒楄〃棰勮鐘舵��")
 	@PreAuthorize("@ss.hasPermi('system:oss:edit')")
-	@Log(title = "OSS浜戝瓨鍌�" , businessType = BusinessType.UPDATE)
+	@Log(title = "OSS瀵硅薄瀛樺偍" , businessType = BusinessType.UPDATE)
 	@PutMapping("/changePreviewListResource")
 	public AjaxResult<Void> changePreviewListResource(@RequestBody String body) {
 		Map<String, Boolean> map = JsonUtils.parseMap(body);

--
Gitblit v1.9.3