From f41688667f84433fafe9ea871264d114ba28b008 Mon Sep 17 00:00:00 2001 From: yuemian <--list> Date: Tue, 27 Aug 2024 15:59:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=AF=B9=E6=8E=A5code?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SystemConfigController.java | 7 +++++++ .../sms/interfaces/SystemConfigService.java | 2 ++ .../sms/service/SystemConfigServiceImpl.java | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/SystemConfigController.java b/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/SystemConfigController.java index 05fdb88..ff7006b 100644 --- a/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/SystemConfigController.java +++ b/bocloud.sms.booter/src/main/java/com/bocloud/sms/booter/controller/SystemConfigController.java @@ -1,6 +1,7 @@ package com.bocloud.sms.booter.controller; import com.alibaba.fastjson.JSONArray; +import com.bocloud.sms.entity.SystemConfig; import com.bocloud.sms.interfaces.SystemConfigService; import com.bocloud.sms.model.ConfigModel; import com.megatron.common.model.GeneralResult; @@ -101,4 +102,10 @@ public class SystemConfigController { public Result configTest(@RequestParam(value = "category") String category) { return systemConfigService.configTest(category); } + + @Operation(summary = "通过code查询系统配置信息") + @GetMapping("/configs/queryByCode") + public GeneralResult queryByCode(@RequestParam(value = "code") String code) { + return systemConfigService.queryByCode(code); + } } diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/SystemConfigService.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/SystemConfigService.java index a1d36f6..c65e497 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/SystemConfigService.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/interfaces/SystemConfigService.java @@ -49,4 +49,6 @@ public interface SystemConfigService { * @return */ Result configTest(String category); + + GeneralResult queryByCode(String code); } diff --git a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/SystemConfigServiceImpl.java b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/SystemConfigServiceImpl.java index 93952dd..577f581 100644 --- a/bocloud.sms.service/src/main/java/com/bocloud/sms/service/SystemConfigServiceImpl.java +++ b/bocloud.sms.service/src/main/java/com/bocloud/sms/service/SystemConfigServiceImpl.java @@ -331,4 +331,25 @@ public class SystemConfigServiceImpl implements SystemConfigService { } return Result.FAILED("测试连接失败"); } + + @Override + public GeneralResult queryByCode(String code) { + String errorMsg; + + try { + SystemConfig config = systemConfigRepository.queryByCode(code); + if (config == null) { + return new GeneralResult<>(false, "未查询到code为" + code + "的配置信息"); + } + String value = config.getValue(); + if (value != null) { + config.setValue(value.trim()); + } + return new GeneralResult<>(true, config, "查询成功"); + } catch (Exception e) { + errorMsg = "通过code查询系统配置信息出错," + e.getMessage(); + log.error(errorMsg, e); + return new GeneralResult<>(false, errorMsg); + } + } }