From 64db44e54273931b95c09a5e86ec90614b1370ec Mon Sep 17 00:00:00 2001 From: KonBAI <1527468660@qq.com> Date: Thu, 10 Feb 2022 02:26:51 +0000 Subject: [PATCH] =?UTF-8?q?!9=20sync=20=E5=90=8C=E6=AD=A5ruoyi-vue-plus?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=20*=20update=20=E6=9B=B4=E6=96=B0=20swagger?= =?UTF-8?q?=20=E6=B3=A8=E8=A7=A3=E7=94=A8=E6=B3=95=20*=20update=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4oss=E9=A2=84=E8=A7=88=E5=BC=80=E5=85=B3=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=89=8D=E7=AB=AF=E7=9B=B4=E6=8E=A5=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=9B=B4=E6=94=B9=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20*=20fix=20=E4=BF=AE=E5=A4=8D=20insertOrUpdateBatch=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=94=99=E8=AF=AF=20class=20=E7=B1=BB=20*=20?= =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/system/SysConfigController.java | 11 +++++++++++ .../web/controller/system/SysProfileController.java | 2 +- .../com/ruoyi/common/core/mapper/BaseMapperPlus.java | 2 +- .../demo/controller/Swagger3DemoController.java | 5 +++-- .../system/service/impl/SysConfigServiceImpl.java | 8 +++++++- ruoyi-ui/src/api/system/config.js | 12 ++++++++++++ ruoyi-ui/src/api/system/oss.js | 10 ---------- ruoyi-ui/src/main.js | 3 ++- ruoyi-ui/src/views/system/oss/index.vue | 4 ++-- 9 files changed, 39 insertions(+), 18 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java index 7c387901..8cbea8eb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -101,6 +101,17 @@ public class SysConfigController extends BaseController { return toAjax(configService.updateConfig(config)); } + /** + * 根据参数键名修改参数配置 + */ + @ApiOperation("根据参数键名修改参数配置") + @SaCheckPermission("system:config:edit") + @Log(title = "参数管理", businessType = BusinessType.UPDATE) + @PutMapping("/updateByKey") + public R updateByKey(@RequestBody SysConfig config) { + return toAjax(configService.updateConfig(config)); + } + /** * 删除参数配置 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index 6ed8454f..c69f0615 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -109,7 +109,7 @@ public class SysProfileController extends BaseController { */ @ApiOperation("头像上传") @ApiImplicitParams({ - @ApiImplicitParam(name = "avatarfile", value = "用户头像", dataTypeClass = File.class, required = true), + @ApiImplicitParam(name = "avatarfile", value = "用户头像", paramType = "query", dataTypeClass = File.class, required = true) }) @Log(title = "用户头像", businessType = BusinessType.UPDATE) @PostMapping("/avatar") diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java index de297935..d3f61950 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java @@ -106,7 +106,7 @@ public interface BaseMapperPlus extends BaseMapper { Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); String keyProperty = tableInfo.getKeyProperty(); Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); - return SqlHelper.saveOrUpdateBatch(this.currentModelClass(), getClass(), log, entityList, batchSize, (sqlSession, entity) -> { + return SqlHelper.saveOrUpdateBatch(this.currentModelClass(), this.currentMapperClass(), log, entityList, batchSize, (sqlSession, entity) -> { Object idVal = tableInfo.getPropertyValue(entity, keyProperty); String sqlStatement = SqlHelper.getSqlStatement(this.currentMapperClass(), SqlMethod.INSERT_ONE); return StringUtils.checkValNull(idVal) diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java index b0f0b3bc..e50ce03a 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/Swagger3DemoController.java @@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.io.File; + /** * swagger3 用法示例 * @@ -24,11 +26,10 @@ public class Swagger3DemoController { /** * 上传请求 * 必须使用 @RequestPart 注解标注为文件 - * dataType 必须为 "java.io.File" */ @ApiOperation(value = "通用上传请求") @ApiImplicitParams({ - @ApiImplicitParam(name = "file", value = "文件", dataType = "java.io.File", required = true), + @ApiImplicitParam(name = "file", value = "文件", paramType = "query", dataTypeClass = File.class, required = true) }) @PostMapping(value = "/upload") public R upload(@RequestPart("file") MultipartFile file) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 3170700b..9e6e6c31 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -136,7 +136,13 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { */ @Override public int updateConfig(SysConfig config) { - int row = baseMapper.updateById(config); + int row = 0; + if (config.getConfigId() != null) { + row = baseMapper.updateById(config); + } else { + row = baseMapper.update(config, new LambdaQueryWrapper() + .eq(SysConfig::getConfigKey, config.getConfigKey())); + } if (row > 0) { RedisUtils.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); } diff --git a/ruoyi-ui/src/api/system/config.js b/ruoyi-ui/src/api/system/config.js index c1932848..02f0cfcd 100644 --- a/ruoyi-ui/src/api/system/config.js +++ b/ruoyi-ui/src/api/system/config.js @@ -43,6 +43,18 @@ export function updateConfig(data) { }) } +// 修改参数配置 +export function updateConfigByKey(key, value) { + return request({ + url: '/system/config/updateByKey', + method: 'put', + data: { + configKey: key, + configValue: value + } + }) +} + // 删除参数配置 export function delConfig(configId) { return request({ diff --git a/ruoyi-ui/src/api/system/oss.js b/ruoyi-ui/src/api/system/oss.js index b98bd1f0..83adca54 100644 --- a/ruoyi-ui/src/api/system/oss.js +++ b/ruoyi-ui/src/api/system/oss.js @@ -17,13 +17,3 @@ export function delOss(ossId) { }) } -export function changePreviewListResource(previewListResource) { - const data = { - previewListResource - } - return request({ - url: '/system/oss/changePreviewListResource', - method: 'put', - data: data - }) -} diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index 13c6cf29..1e0144f4 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -17,7 +17,7 @@ import { download } from '@/utils/request' import './assets/icons' // icon import './permission' // permission control import { getDicts } from "@/api/system/dict/data"; -import { getConfigKey } from "@/api/system/config"; +import { getConfigKey, updateConfigByKey } from "@/api/system/config"; import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi"; // 分页组件 import Pagination from "@/components/Pagination"; @@ -41,6 +41,7 @@ import DictData from '@/components/DictData' // 全局方法挂载 Vue.prototype.getDicts = getDicts Vue.prototype.getConfigKey = getConfigKey +Vue.prototype.updateConfigByKey = updateConfigByKey Vue.prototype.parseTime = parseTime Vue.prototype.resetForm = resetForm Vue.prototype.addDateRange = addDateRange diff --git a/ruoyi-ui/src/views/system/oss/index.vue b/ruoyi-ui/src/views/system/oss/index.vue index fdfed165..ac8b0297 100644 --- a/ruoyi-ui/src/views/system/oss/index.vue +++ b/ruoyi-ui/src/views/system/oss/index.vue @@ -187,7 +187,7 @@