diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 6f60b47dda..7ee18ac83a 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -40,17 +40,24 @@ public class SystemParameterService { public void editMail(List parameters) { List paramList = this.getParamList(ParamConstants.Classify.MAIL.getValue()); - boolean empty = paramList.size() < 2; + boolean empty = paramList.size() <= 0; + parameters.forEach(parameter -> { + SystemParameterExample example = new SystemParameterExample(); if (parameter.getParamKey().equals(ParamConstants.MAIL.PASSWORD.getKey())) { - String string = EncryptUtils.aesEncrypt(parameter.getParamValue()).toString(); - parameter.setParamValue(string); + if (!StringUtils.isBlank(parameter.getParamValue())) { + String string = EncryptUtils.aesEncrypt(parameter.getParamValue()).toString(); + parameter.setParamValue(string); + } } - if (empty) { - systemParameterMapper.insert(parameter); - } else { + example.createCriteria().andParamKeyEqualTo(parameter.getParamKey()); + if (systemParameterMapper.countByExample(example) > 0) { systemParameterMapper.updateByPrimaryKey(parameter); + } else { + systemParameterMapper.insert(parameter); } + example.clear(); + }); } @@ -105,8 +112,11 @@ public class SystemParameterService { } } else { paramList.stream().filter(param -> param.getParamKey().equals(ParamConstants.MAIL.PASSWORD.getKey())).forEach(param -> { - String string = EncryptUtils.aesDecrypt(param.getParamValue()).toString(); - param.setParamValue(string); + if (!StringUtils.isBlank(param.getParamValue())) { + String string = EncryptUtils.aesDecrypt(param.getParamValue()).toString(); + param.setParamValue(string); + } + }); } paramList.sort(Comparator.comparingInt(SystemParameter::getSort)); diff --git a/frontend/src/business/components/settings/system/SystemParameterSetting.vue b/frontend/src/business/components/settings/system/SystemParameterSetting.vue index 8c30d63387..2d9ade2b79 100644 --- a/frontend/src/business/components/settings/system/SystemParameterSetting.vue +++ b/frontend/src/business/components/settings/system/SystemParameterSetting.vue @@ -127,9 +127,15 @@ this.$set(this.formInline, "port", response.data[1].paramValue); this.$set(this.formInline, "account", response.data[2].paramValue); this.$set(this.formInline, "password", response.data[3].paramValue); - this.$set(this.formInline, "SSL", JSON.parse(response.data[4].paramValue)); - this.$set(this.formInline, "TLS", JSON.parse(response.data[5].paramValue)); - this.$set(this.formInline, "SMTP", JSON.parse(response.data[6].paramValue)); + if(response.data[4].paramValue!=""){ + this.$set(this.formInline, "SSL", JSON.parse(response.data[4].paramValue)); + } + if(response.data[5].paramValue!=""){ + this.$set(this.formInline, "TLS", JSON.parse(response.data[5].paramValue)); + } + if(response.data[6].paramValue!=""){ + this.$set(this.formInline, "SMTP", JSON.parse(response.data[6].paramValue)); + } }) }, change() {