diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ParamConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ParamConstants.java index 9637db2a48..8e2b842787 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ParamConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ParamConstants.java @@ -50,7 +50,7 @@ public interface ParamConstants { FROM("smtp.from"), PASSWORD("smtp.password"), SSL("smtp.ssl"), - TLS("smtp.tls"), + TSL("smtp.tsl"), RECIPIENTS("smtp.recipient"); private String value; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseSystemParameterMapper.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseSystemParameterMapper.java new file mode 100644 index 0000000000..9c86596f19 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseSystemParameterMapper.java @@ -0,0 +1,8 @@ +package io.metersphere.sdk.mapper; + +import org.apache.ibatis.annotations.Param; + +public interface BaseSystemParameterMapper { + + void saveBaseUrl(@Param("baseUrl") String baseUrl); +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseSystemParameterMapper.xml b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseSystemParameterMapper.xml new file mode 100644 index 0000000000..221b1fb244 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseSystemParameterMapper.xml @@ -0,0 +1,9 @@ + + + + + + UPDATE system_parameter SET param_value = #{baseUrl} + WHERE param_key = 'base.url' AND (param_value LIKE 'http://127%' OR param_value = '' OR param_value IS NULL) + + \ No newline at end of file diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/notice/sender/impl/MailNoticeSender.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/notice/sender/impl/MailNoticeSender.java index 09fad632f8..94a496898c 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/notice/sender/impl/MailNoticeSender.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/notice/sender/impl/MailNoticeSender.java @@ -29,8 +29,8 @@ public class MailNoticeSender extends AbstractNoticeSender { javaMailSender.setProtocol("smtps"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); } - if (BooleanUtils.toBoolean(paramMap.get(ParamConstants.MAIL.TLS.getValue()))) { - String result = BooleanUtils.toString(BooleanUtils.toBoolean(paramMap.get(ParamConstants.MAIL.TLS.getValue())), "true", "false"); + if (BooleanUtils.toBoolean(paramMap.get(ParamConstants.MAIL.TSL.getValue()))) { + String result = BooleanUtils.toString(BooleanUtils.toBoolean(paramMap.get(ParamConstants.MAIL.TSL.getValue())), "true", "false"); props.put("mail.smtp.starttls.enable", result); props.put("mail.smtp.starttls.required", result); } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java index 658fd90716..f2356c57d3 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/SystemParameterService.java @@ -8,6 +8,7 @@ import io.metersphere.sdk.dto.LogDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.log.constants.OperationLogModule; import io.metersphere.sdk.log.constants.OperationLogType; +import io.metersphere.sdk.mapper.BaseSystemParameterMapper; import io.metersphere.sdk.notice.sender.impl.MailNoticeSender; import io.metersphere.sdk.util.EncryptUtils; import io.metersphere.sdk.util.JSON; @@ -40,6 +41,9 @@ public class SystemParameterService { @Resource MailNoticeSender mailNoticeSender; + @Resource + BaseSystemParameterMapper baseSystemParameterMapper; + public void saveBaseInfo(List parameters) { SystemParameterExample example = new SystemParameterExample(); parameters.forEach(param -> { @@ -122,7 +126,7 @@ public class SystemParameterService { mailInfo.setPassword(password); } else if (StringUtils.equals(param.getParamKey(), ParamConstants.MAIL.SSL.getValue())) { mailInfo.setSsl(param.getParamValue()); - } else if (StringUtils.equals(param.getParamKey(), ParamConstants.MAIL.TLS.getValue())) { + } else if (StringUtils.equals(param.getParamKey(), ParamConstants.MAIL.TSL.getValue())) { mailInfo.setTsl(param.getParamValue()); } else if (StringUtils.equals(param.getParamKey(), ParamConstants.MAIL.RECIPIENTS.getValue())) { mailInfo.setRecipient(param.getParamValue()); @@ -261,4 +265,8 @@ public class SystemParameterService { }); return originalValue; } + + public void saveBaseUrl(String baseUrl) { + baseSystemParameterMapper.saveBaseUrl(baseUrl); + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java index 8113bd7413..885372b5b8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java @@ -10,7 +10,7 @@ import io.metersphere.sdk.log.vo.OperationLogRequest; import io.metersphere.sdk.log.vo.OperationLogResponse; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; -import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse; import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.SystemProjectService; @@ -46,9 +46,9 @@ public class OperationLogController { public OrganizationProjectOptionsResponse getOptions() { //获取全部组织 - List organizationList = organizationService.getOrganizationOptions(); + List organizationList = organizationService.getOrganizationOptions(); //获取全部项目 - List projectList = systemProjectService.getProjectOptions(); + List projectList = systemProjectService.getProjectOptions(); OrganizationProjectOptionsResponse optionsResponse = new OrganizationProjectOptionsResponse(); optionsResponse.setOrganizationList(organizationList); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java index 9e77ea7e1f..ef0e461ecb 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemParameterController.java @@ -68,4 +68,10 @@ public class SystemParameterController { systemParameterService.testEmailConnection(hashMap); } + + @GetMapping("/save/base-url") + public void saveBaseurl(@RequestParam("baseUrl") String baseUrl) { + systemParameterService.saveBaseUrl(baseUrl); + } + } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDto.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDTO.java similarity index 68% rename from backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDto.java rename to backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDTO.java index 3e11638c28..c5ca44e9f0 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDto.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationProjectOptionsDTO.java @@ -4,7 +4,7 @@ package io.metersphere.system.dto; import lombok.Data; @Data -public class OrganizationProjectOptionsDto { +public class OrganizationProjectOptionsDTO { String id; String name; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java index a5d27187c7..ec80d1e4bf 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/response/OrganizationProjectOptionsResponse.java @@ -1,6 +1,6 @@ package io.metersphere.system.dto.response; -import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import lombok.Data; import java.util.List; @@ -8,6 +8,6 @@ import java.util.List; @Data public class OrganizationProjectOptionsResponse { - List organizationList; - List projectList; + List organizationList; + List projectList; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java index 482fd6c746..ea69f6326f 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java @@ -3,7 +3,7 @@ package io.metersphere.system.mapper; import io.metersphere.system.domain.User; import io.metersphere.system.dto.OrgUserExtend; import io.metersphere.system.dto.OrganizationDTO; -import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.OrganizationDeleteRequest; import io.metersphere.system.request.OrganizationRequest; @@ -74,5 +74,5 @@ public interface ExtOrganizationMapper { * 获取组织列表(下拉框) * @return 组织列表数据 */ - List selectOrganizationOptions(); + List selectOrganizationOptions(); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml index e22464f2aa..a0f440daa9 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml @@ -74,7 +74,7 @@ where urr.role_id = 'org_admin'and urr.source_id = #{orgId} - select id, name from organization order by create_time desc diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java index 01797e62da..099e2474bd 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.java @@ -2,7 +2,7 @@ package io.metersphere.system.mapper; import io.metersphere.sdk.dto.ProjectDTO; import io.metersphere.system.domain.User; -import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.ProjectMemberRequest; import io.metersphere.system.request.ProjectRequest; @@ -18,5 +18,5 @@ public interface ExtSystemProjectMapper { List getProjectAdminList(String projectId); - List selectProjectOptions(); + List selectProjectOptions(); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml index bfd716c374..3a0b247641 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtSystemProjectMapper.xml @@ -53,7 +53,7 @@ - select id, name from project order by create_time desc diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java index 9b5393e499..0a8255f4b0 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java @@ -16,7 +16,7 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.*; import io.metersphere.system.dto.OrgUserExtend; import io.metersphere.system.dto.OrganizationDTO; -import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.mapper.*; import io.metersphere.system.request.*; @@ -207,7 +207,7 @@ public class OrganizationService { return organizationDTOS; } - public List getOrganizationOptions() { + public List getOrganizationOptions() { return extOrganizationMapper.selectOrganizationOptions(); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java index 83f0452528..a369ca2338 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/SystemProjectService.java @@ -20,7 +20,7 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.User; import io.metersphere.system.domain.UserRoleRelation; import io.metersphere.system.domain.UserRoleRelationExample; -import io.metersphere.system.dto.OrganizationProjectOptionsDto; +import io.metersphere.system.dto.OrganizationProjectOptionsDTO; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.mapper.ExtSystemProjectMapper; import io.metersphere.system.mapper.UserMapper; @@ -302,7 +302,7 @@ public class SystemProjectService { userRoleRelationMapper.deleteByExample(userGroupExample); } - public List getProjectOptions() { + public List getProjectOptions() { return extSystemProjectMapper.selectProjectOptions(); } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java index f6c1635eeb..8a72f87e82 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java @@ -41,11 +41,21 @@ public class SystemParameterControllerTests extends BaseTest { public static final String EMAIL_INFO_TEST_CONNECT_URL = "/system/parameter/test/email"; + public static final String SAVE_BASE_URL = "/system/parameter/save/base-url"; + public static final String BASE_URL = "http://www.baidu.com"; + private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError(); @Test @Order(1) + public void testSaveBaseUrl() throws Exception { + this.requestGet(SAVE_BASE_URL + "?baseUrl=" + BASE_URL); + } + + + @Test + @Order(2) public void testSaveBaseInfo() throws Exception { List systemParameters = new ArrayList<>() {{