From 652a39b11cca6ad85aea399b2f12e6694d2a2b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 13 Aug 2021 14:04:57 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E6=AD=A3=20PR=20=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysOssController.java | 21 +++++++++ .../service/impl/SysOssConfigServiceImpl.java | 2 +- ruoyi-ui/src/api/system/oss.js | 11 +++++ ruoyi-ui/src/views/system/oss/config.vue | 21 ++++++--- ruoyi-ui/src/views/system/oss/index.vue | 46 +++++++++++++++---- 5 files changed, 84 insertions(+), 17 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 76101972..08d7e7ee 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 @@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system; import cn.hutool.core.convert.Convert; 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; @@ -10,10 +11,14 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.utils.JsonUtils; import com.ruoyi.common.utils.file.FileUtils; +import com.ruoyi.oss.constant.CloudConstant; +import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.SysOss; import com.ruoyi.system.domain.bo.SysOssBo; import com.ruoyi.system.domain.vo.SysOssVo; +import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysOssService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -49,6 +54,7 @@ import java.util.Map; public class SysOssController extends BaseController { private final ISysOssService iSysOssService; + private final ISysConfigService iSysConfigService; /** * 查询OSS云存储列表 @@ -111,4 +117,19 @@ public class SysOssController extends BaseController { return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); } + /** + * 变更图片列表预览状态 + */ + @ApiOperation("变更图片列表预览状态") + @PreAuthorize("@ss.hasPermi('system:oss:edit')") + @Log(title = "OSS云存储" , businessType = BusinessType.UPDATE) + @PutMapping("/changePreviewListResource") + public AjaxResult changePreviewListResource(@RequestBody String body) { + Map map = JsonUtils.parseMap(body); + SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper() + .eq(SysConfig::getConfigKey, CloudConstant.PEREVIEW_LIST_RESOURCE_KEY)); + config.setConfigValue(map.get("previewListResource").toString()); + return toAjax(iSysConfigService.updateConfig(config)); + } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java index 1de76ae8..95f08696 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java @@ -88,7 +88,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl ids, Boolean isValid) { if(isValid) { - if (CollUtil.containsAll(ids, CollUtil.newArrayList(1, 2, 3, 4))) { + if (CollUtil.containsAny(ids, CollUtil.newArrayList(1, 2, 3, 4))) { throw new CustomException("系统内置, 不可删除!"); } } diff --git a/ruoyi-ui/src/api/system/oss.js b/ruoyi-ui/src/api/system/oss.js index 39be5971..965f137a 100644 --- a/ruoyi-ui/src/api/system/oss.js +++ b/ruoyi-ui/src/api/system/oss.js @@ -16,3 +16,14 @@ export function delOss(ossId) { method: 'delete' }) } + +export function changePreviewListResource(previewListResource) { + const data = { + previewListResource + } + return request({ + url: '/system/oss/changePreviewListResource', + method: 'put', + data: data + }) +} diff --git a/ruoyi-ui/src/views/system/oss/config.vue b/ruoyi-ui/src/views/system/oss/config.vue index 9cd528c5..446085c4 100644 --- a/ruoyi-ui/src/views/system/oss/config.vue +++ b/ruoyi-ui/src/views/system/oss/config.vue @@ -345,6 +345,12 @@ export default { this.resetForm("queryForm"); this.handleQuery(); }, + // 多选框选中数据 + handleSelectionChange(selection) { + this.ids = selection.map(item => item.ossConfigId) + this.single = selection.length!==1 + this.multiple = !selection.length + }, /** 新增按钮操作 */ handleAdd() { this.reset(); @@ -402,7 +408,9 @@ export default { this.loading = false; this.getList(); this.msgSuccess("删除成功"); - }).catch(() => {}); + }).finally(() => { + this.loading = false; + }); }, // 云存储配置状态修改 handleStatusChange(row) { @@ -412,16 +420,15 @@ export default { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", - }).then(function () { + }).then(() => { return changeOssConfigStatus(row.ossConfigId, row.status, row.configKey); }).then(() => { this.getList() this.msgSuccess(text + "成功"); - }).catch(function () { + }).catch(() => { row.status = row.status === "0" ? "1" : "0"; - }).finally(() => { - }); - }, - }, + }) + } + } }; diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue index e8e471e4..2bbbba06 100644 --- a/ruoyi-ui/src/views/system/oss/index.vue +++ b/ruoyi-ui/src/views/system/oss/index.vue @@ -96,6 +96,15 @@ v-hasPermi="['system:oss:remove']" >删除 + + 预览开关 : {{previewListResource ? "禁用" : "启用"}} +