From b082da73a1e0259738ccb33ebf7d80cad3dc3a10 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 27 九月 2021 17:27:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into satoken --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 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 47e9032..4acc311 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 @@ -1,8 +1,10 @@ package com.ruoyi.web.controller.system; +import cn.dev33.satoken.annotation.SaCheckPermission; 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; @@ -29,7 +31,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -62,7 +63,7 @@ * 鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃 */ @ApiOperation("鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃") - @PreAuthorize("@ss.hasPermi('system:oss:list')") + @SaCheckPermission("system:oss:list") @GetMapping("/list") public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo) { return iSysOssService.queryPageList(bo); @@ -75,7 +76,7 @@ @ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "鏂囦欢", dataType = "java.io.File", required = true), }) - @PreAuthorize("@ss.hasPermi('system:oss:upload')") + @SaCheckPermission("system:oss:upload") @Log(title = "OSS瀵硅薄瀛樺偍", businessType = BusinessType.INSERT) @RepeatSubmit @PostMapping("/upload") @@ -91,7 +92,7 @@ } @ApiOperation("涓嬭浇OSS瀵硅薄瀛樺偍") - @PreAuthorize("@ss.hasPermi('system:oss:download')") + @SaCheckPermission("system:oss:download") @GetMapping("/download/{ossId}") public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { SysOss sysOss = iSysOssService.getById(ossId); @@ -103,7 +104,16 @@ response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); FileUtils.setAttachmentResponseHeader(response, URLEncoder.encode(sysOss.getOriginalName(), StandardCharsets.UTF_8.toString())); 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)); } @@ -111,7 +121,7 @@ * 鍒犻櫎OSS瀵硅薄瀛樺偍 */ @ApiOperation("鍒犻櫎OSS瀵硅薄瀛樺偍") - @PreAuthorize("@ss.hasPermi('system:oss:remove')") + @SaCheckPermission("system:oss:remove") @Log(title = "OSS瀵硅薄瀛樺偍" , businessType = BusinessType.DELETE) @DeleteMapping("/{ossIds}") public AjaxResult<Void> remove(@NotEmpty(message = "涓婚敭涓嶈兘涓虹┖") @@ -123,7 +133,7 @@ * 鍙樻洿鍥剧墖鍒楄〃棰勮鐘舵�� */ @ApiOperation("鍙樻洿鍥剧墖鍒楄〃棰勮鐘舵��") - @PreAuthorize("@ss.hasPermi('system:oss:edit')") + @SaCheckPermission("system:oss:edit") @Log(title = "OSS瀵硅薄瀛樺偍" , businessType = BusinessType.UPDATE) @PutMapping("/changePreviewListResource") public AjaxResult<Void> changePreviewListResource(@RequestBody String body) { -- Gitblit v1.9.3