diff --git a/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java b/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java index 0a96536d40f89c1018d70995762954f11379cddf..e2fe313ed2bfbe5fad08beaa755856416cee7895 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java @@ -85,6 +85,7 @@ public interface ParamConstants { this.value = value; } } + public static enum MAIL { HOST("meter.host", 1), PORT("meter.port", 2), diff --git a/backend/src/main/java/io/metersphere/controller/SystemParameterController.java b/backend/src/main/java/io/metersphere/controller/SystemParameterController.java index 1d02d58302a52c5e9b95583778138b10112f5896..3dc6c620b3f34ad5daa74cc2332819be1db7f410 100644 --- a/backend/src/main/java/io/metersphere/controller/SystemParameterController.java +++ b/backend/src/main/java/io/metersphere/controller/SystemParameterController.java @@ -15,13 +15,15 @@ import java.util.List; @RequestMapping(value = "/system") public class SystemParameterController { @Resource - private SystemParameterService SystemParameterService; + private SystemParameterService SystemParameterService; + @PostMapping("/edit/email") - public void editMail(@RequestBody List SystemParameter){ - SystemParameterService.editMail(SystemParameter); + public void editMail(@RequestBody List systemParameter) { + SystemParameterService.editMail(systemParameter); } + @PostMapping("/testConnection") - public void testConnection(@RequestBody HashMap hashMap){ + public void testConnection(@RequestBody HashMap hashMap) { SystemParameterService.testConnection(hashMap); } diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 7b98a8a6dc29b857d3ec13c8a8acef953ab64ca6..e6d4635a406b52a30c0765156a8603feb0fd9657 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -9,6 +9,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; + import java.util.HashMap; import java.util.List; import java.util.Properties; @@ -16,7 +17,6 @@ import java.util.Properties; import org.springframework.mail.javamail.JavaMailSenderImpl; - import javax.annotation.Resource; @@ -39,7 +39,8 @@ public class SystemParameterService { } return result; } - public void editMail(List parameters){ + + public void editMail(List parameters) { List paramList = this.getParamList(ParamConstants.Classify.MAIL.getValue()); boolean empty = paramList.size() < 2; parameters.forEach(parameter -> { @@ -54,13 +55,14 @@ public class SystemParameterService { } }); } + public List getParamList(String type) { SystemParameterExample example = new SystemParameterExample(); example.createCriteria().andParamKeyLike(type + "%"); return systemParameterMapper.selectByExample(example); } - public void testConnection(HashMap hashMap){ + public void testConnection(HashMap hashMap) { JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); javaMailSender.setDefaultEncoding("UTF-8"); javaMailSender.setHost(hashMap.get(ParamConstants.MAIL.PORT.getKey())); diff --git a/frontend/src/business/components/settings/system/SystemParameterSetting.vue b/frontend/src/business/components/settings/system/SystemParameterSetting.vue index c8cd98cb381b3e91ccae0091a3e9aca1135f7fef..6da016eceb71bb047cf451855882e8b3c7aca496 100644 --- a/frontend/src/business/components/settings/system/SystemParameterSetting.vue +++ b/frontend/src/business/components/settings/system/SystemParameterSetting.vue @@ -12,7 +12,7 @@ + v-on:input="change()"> @@ -20,7 +20,7 @@ + v-on:input="change()"> @@ -28,7 +28,7 @@ + v-on:input="change()"> @@ -114,30 +114,8 @@ methods: { - host() { - let host = this.formInline.host; - if (!host) { - this.disabledConnection = true; - this.disabledSave = true; - } else { - this.disabledConnection = false; - this.disabledSave = false; - } - }, - port() { - - let port = this.formInline.port; - if (!port) { - this.disabledConnection = true; - this.disabledSave = true; - } else { - this.disabledConnection = false; - this.disabledSave = false; - } - }, - account() { - let account = this.formInline.account; - if (!account) { + change() { + if (!this.formInline.host || !this.formInline.port || !this.formInline.account) { this.disabledConnection = true; this.disabledSave = true; } else {