| | |
| | | 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; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "OSS对象存储控制器", tags = {"OSS对象存储管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/oss") |
| | | public class SysOssController extends BaseController { |
| | |
| | | @ApiOperation("查询OSS对象存储列表") |
| | | @SaCheckPermission("system:oss:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo) { |
| | | return iSysOssService.queryPageList(bo); |
| | | public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) { |
| | | return iSysOssService.queryPageList(bo, pageQuery); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping("/upload") |
| | | public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | if (ObjectUtil.isNull(file)) { |
| | | throw new ServiceException("上传文件不能为空"); |
| | | } |
| | |
| | | Map<String, String> map = new HashMap<>(2); |
| | | map.put("url", oss.getUrl()); |
| | | map.put("fileName", oss.getFileName()); |
| | | return AjaxResult.success(map); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("下载OSS对象存储") |
| | |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("OSS对象ID串") |
| | | public R<Void> remove(@ApiParam("OSS对象ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); |
| | |
| | | @SaCheckPermission("system:oss:edit") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changePreviewListResource") |
| | | public AjaxResult<Void> changePreviewListResource(@RequestBody String body) { |
| | | public R<Void> changePreviewListResource(@RequestBody String body) { |
| | | Map<String, Boolean> map = JsonUtils.parseMap(body); |
| | | SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>() |
| | | .eq(SysConfig::getConfigKey, OssConstant.PEREVIEW_LIST_RESOURCE_KEY)); |
| | | SysConfig sysConfig = new SysConfig(); |
| | | sysConfig.setConfigKey(OssConstant.PEREVIEW_LIST_RESOURCE_KEY); |
| | | SysConfig config = iSysConfigService.getOne(sysConfig); |
| | | config.setConfigValue(map.get("previewListResource").toString()); |
| | | return toAjax(iSysConfigService.updateConfig(config)); |
| | | } |