From 9887cf5904888a22692eee9b464630fab8929c06 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 21 May 2020 14:04:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/constants/ParamConstants.java | 1 + .../controller/SystemParameterController.java | 10 +++--- .../service/SystemParameterService.java | 8 +++-- .../system/SystemParameterSetting.vue | 32 +++---------------- 4 files changed, 17 insertions(+), 34 deletions(-) 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 0a96536d40..e2fe313ed2 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 1d02d58302..3dc6c620b3 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 7b98a8a6dc..e6d4635a40 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 c8cd98cb38..6da016eceb 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 {