From 652a39b11cca6ad85aea399b2f12e6694d2a2b39 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期五, 13 八月 2021 14:04:57 +0800 Subject: [PATCH] update 修正 PR 相关问题 --- ruoyi-ui/src/api/system/oss.js | 11 +++++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java | 21 ++++++++++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java | 2 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 7610197..08d7e7e 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 @@ 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.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 @@ public class SysOssController extends BaseController { private final ISysOssService iSysOssService; + private final ISysConfigService iSysConfigService; /** * 鏌ヨOSS浜戝瓨鍌ㄥ垪琛� @@ -111,4 +117,19 @@ 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<Void> changePreviewListResource(@RequestBody String body) { + Map<String, Boolean> map = JsonUtils.parseMap(body); + SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>() + .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 1de76ae..95f0869 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 @@ @Override public Boolean deleteWithValidByIds(Collection<Integer> 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 39be597..965f137 100644 --- a/ruoyi-ui/src/api/system/oss.js +++ b/ruoyi-ui/src/api/system/oss.js @@ -16,3 +16,14 @@ 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 9cd528c..446085c 100644 --- a/ruoyi-ui/src/views/system/oss/config.vue +++ b/ruoyi-ui/src/views/system/oss/config.vue @@ -345,6 +345,12 @@ 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 @@ this.loading = false; this.getList(); this.msgSuccess("鍒犻櫎鎴愬姛"); - }).catch(() => {}); + }).finally(() => { + this.loading = false; + }); }, // 浜戝瓨鍌ㄩ厤缃姸鎬佷慨鏀� handleStatusChange(row) { @@ -412,16 +420,15 @@ 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(() => { - }); - }, - }, + }) + } + } }; </script> diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue index e8e471e..2bbbba0 100644 --- a/ruoyi-ui/src/views/system/oss/index.vue +++ b/ruoyi-ui/src/views/system/oss/index.vue @@ -98,6 +98,15 @@ </el-col> <el-col :span="1.5"> <el-button + :type="previewListResource ? 'danger' : 'warning'" + plain + size="mini" + @click="handlePreviewListResource(!previewListResource)" + v-hasPermi="['system:oss:edit']" + >棰勮寮�鍏� : {{previewListResource ? "绂佺敤" : "鍚敤"}}</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="info" plain icon="el-icon-s-operation" @@ -178,7 +187,7 @@ </template> <script> -import { listOss, delOss } from "@/api/system/oss"; +import { listOss, delOss, changePreviewListResource } from "@/api/system/oss"; import { downLoadOss } from "@/utils/download"; export default { @@ -325,14 +334,33 @@ confirmButtonText: "纭畾", cancelButtonText: "鍙栨秷", type: "warning" - }).then(() => { - this.loading = true; - return delOss(ossIds); - }).then(() => { - this.loading = false; - this.getList(); - this.msgSuccess("鍒犻櫎鎴愬姛"); - }).catch(() => {}); + }).then(() => { + this.loading = true; + return delOss(ossIds); + }).then(() => { + this.loading = false; + this.getList(); + this.msgSuccess("鍒犻櫎鎴愬姛"); + }).finally(() => { + this.loading = false; + }); + }, + // 棰勮鍒楄〃鍥剧墖鐘舵�佷慨鏀� + handlePreviewListResource(previewListResource) { + let text = previewListResource ? "鍚敤" : "鍋滅敤"; + this.$confirm( + '纭瑕�"' + text + '""棰勮鍒楄〃鍥剧墖"閰嶇疆鍚�?', "璀﹀憡", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }).then(() => { + return changePreviewListResource(previewListResource); + }).then(() => { + this.getList() + this.msgSuccess(text + "鎴愬姛"); + }).catch(() => { + this.previewListResource = previewListResource !== true; + }) } } }; -- Gitblit v1.9.3