ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOssController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-ui/src/api/system/oss.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-ui/src/views/system/oss/config.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-ui/src/views/system/oss/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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)); } } 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("系统内置, 不可删除!"); } } 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 }) } 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> 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; }) } } };