Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
7f06194c
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 大约 3 年
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7f06194c
编写于
5月 20, 2020
作者:
W
wenyann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
邮件服务设置
上级
c066d994
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
384 addition
and
5 deletion
+384
-5
backend/pom.xml
backend/pom.xml
+4
-1
backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java
...java/io/metersphere/commons/constants/ParamConstants.java
+26
-1
backend/src/main/java/io/metersphere/controller/SystemParameterController.java
.../io/metersphere/controller/SystemParameterController.java
+28
-0
backend/src/main/java/io/metersphere/service/SystemParameterService.java
...n/java/io/metersphere/service/SystemParameterService.java
+48
-1
frontend/src/business/components/common/router/router.js
frontend/src/business/components/common/router/router.js
+7
-1
frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue
...performance/test/components/PerformanceAdvancedConfig.vue
+3
-1
frontend/src/business/components/settings/SettingMenu.vue
frontend/src/business/components/settings/SettingMenu.vue
+1
-0
frontend/src/business/components/settings/system/SystemParameterSetting.vue
...ess/components/settings/system/SystemParameterSetting.vue
+236
-0
frontend/src/i18n/en-US.js
frontend/src/i18n/en-US.js
+16
-0
frontend/src/i18n/zh-CN.js
frontend/src/i18n/zh-CN.js
+15
-0
未找到文件。
backend/pom.xml
浏览文件 @
7f06194c
...
...
@@ -63,7 +63,10 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jetty
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-mail
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
...
...
backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java
浏览文件 @
7f06194c
...
...
@@ -28,7 +28,7 @@ public interface ParamConstants {
}
enum
Classify
implements
ParamConstants
{
MAIL
(
"meter"
),
REGISTRY
(
"registry"
);
private
String
value
;
...
...
@@ -85,4 +85,29 @@ public interface ParamConstants {
this
.
value
=
value
;
}
}
public
static
enum
MAIL
{
HOST
(
"meter.host"
,
1
),
PORT
(
"meter.port"
,
2
),
ACCOUNT
(
"meter.account"
,
3
),
PASSWORD
(
"meter.password"
,
4
),
SSL
(
"meter.ssl"
,
5
),
TLS
(
"meter.tls"
,
6
),
ANON
(
"meter.anon"
,
7
);
private
String
key
;
private
Integer
value
;
private
MAIL
(
String
key
,
Integer
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
String
getKey
()
{
return
this
.
key
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
}
}
backend/src/main/java/io/metersphere/controller/SystemParameterController.java
0 → 100644
浏览文件 @
7f06194c
package
io.metersphere.controller
;
import
io.metersphere.base.domain.SystemParameter
;
import
io.metersphere.service.SystemParameterService
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.List
;
@RestController
@RequestMapping
(
value
=
"/system"
)
public
class
SystemParameterController
{
@Resource
private
SystemParameterService
SystemParameterService
;
@PostMapping
(
"/edit/email"
)
public
void
editMail
(
@RequestBody
List
<
SystemParameter
>
SystemParameter
){
SystemParameterService
.
editMail
(
SystemParameter
);
}
@PostMapping
(
"/testConnection"
)
public
void
testConnection
(
@RequestBody
HashMap
<
String
,
String
>
hashMap
){
SystemParameterService
.
testConnection
(
hashMap
);
}
}
backend/src/main/java/io/metersphere/service/SystemParameterService.java
浏览文件 @
7f06194c
...
...
@@ -4,14 +4,22 @@ import io.metersphere.base.domain.SystemParameter;
import
io.metersphere.base.domain.SystemParameterExample
;
import
io.metersphere.base.mapper.SystemParameterMapper
;
import
io.metersphere.commons.constants.ParamConstants
;
import
io.metersphere.commons.utils.EncryptUtils
;
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
;
import
org.springframework.mail.javamail.JavaMailSenderImpl
;
import
javax.annotation.Resource
;
@Service
public
class
SystemParameterService
{
...
...
@@ -31,4 +39,43 @@ public class SystemParameterService {
}
return
result
;
}
public
void
editMail
(
List
<
SystemParameter
>
parameters
){
List
<
SystemParameter
>
paramList
=
this
.
getParamList
(
ParamConstants
.
Classify
.
MAIL
.
getValue
());
boolean
empty
=
paramList
.
size
()
<
2
;
parameters
.
forEach
(
parameter
->
{
if
(
parameter
.
getParamKey
().
equals
(
ParamConstants
.
MAIL
.
PASSWORD
.
getKey
()))
{
String
string
=
EncryptUtils
.
aesEncrypt
(
parameter
.
getParamValue
()).
toString
();
parameter
.
setParamValue
(
string
);
}
if
(
empty
)
{
systemParameterMapper
.
insert
(
parameter
);
}
else
{
systemParameterMapper
.
updateByPrimaryKey
(
parameter
);
}
});
}
public
List
<
SystemParameter
>
getParamList
(
String
type
)
{
SystemParameterExample
example
=
new
SystemParameterExample
();
example
.
createCriteria
().
andParamKeyLike
(
type
+
"%"
);
return
systemParameterMapper
.
selectByExample
(
example
);
}
public
void
testConnection
(
HashMap
<
String
,
String
>
hashMap
){
JavaMailSenderImpl
javaMailSender
=
new
JavaMailSenderImpl
();
javaMailSender
.
setDefaultEncoding
(
"UTF-8"
);
javaMailSender
.
setHost
(
hashMap
.
get
(
ParamConstants
.
MAIL
.
PORT
.
getKey
()));
javaMailSender
.
setPort
(
Integer
.
valueOf
(
hashMap
.
get
(
ParamConstants
.
MAIL
.
PORT
.
getKey
())));
javaMailSender
.
setUsername
(
hashMap
.
get
(
ParamConstants
.
MAIL
.
ACCOUNT
.
getKey
()));
javaMailSender
.
setPassword
(
hashMap
.
get
(
ParamConstants
.
MAIL
.
PASSWORD
.
getKey
()));
Properties
props
=
new
Properties
();
props
.
put
(
"mail.smtp.auth"
,
"true"
);
if
(
BooleanUtils
.
toBoolean
(
hashMap
.
get
(
ParamConstants
.
MAIL
.
SSL
.
getKey
())))
{
props
.
put
(
"mail.smtp.socketFactory.class"
,
"javax.net.ssl.SSLSocketFactory"
);
}
if
(
BooleanUtils
.
toBoolean
(
hashMap
.
get
(
ParamConstants
.
MAIL
.
TLS
.
getKey
())))
{
props
.
put
(
"mail.smtp.starttls.enable"
,
"true"
);
}
javaMailSender
.
setJavaMailProperties
(
props
);
}
}
frontend/src/business/components/common/router/router.js
浏览文件 @
7f06194c
...
...
@@ -10,6 +10,7 @@ import OrganizationMember from "../../settings/organization/OrganizationMember";
import
Member
from
"
../../settings/workspace/WorkspaceMember
"
;
import
TestCaseReportTemplate
from
"
../../settings/workspace/TestCaseReportTemplate
"
;
import
TestResourcePool
from
"
../../settings/system/TestResourcePool
"
;
import
SystemParameterSetting
from
"
../../settings/system/SystemParameterSetting
"
;
import
MsProject
from
"
../../project/MsProject
"
;
import
OrganizationWorkspace
from
"
../../settings/organization/OrganizationWorkspace
"
;
import
PersonSetting
from
"
../../settings/personal/PersonSetting
"
;
...
...
@@ -80,11 +81,16 @@ const router = new VueRouter({
path
:
'
testresourcepool
'
,
component
:
TestResourcePool
},
{
path
:
'
systemparametersetting
'
,
component
:
SystemParameterSetting
},
{
path
:
'
testcase/report/template
'
,
name
:
'
testCaseReportTemplate
'
,
component
:
TestCaseReportTemplate
}
},
]
},
{
...
...
frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue
浏览文件 @
7f06194c
<
template
>
<div>
<!--Domain name binding-->
<el-row
type=
"flex"
justify=
"start"
>
<el-col
:span=
"8"
>
<h3>
{{
$t
(
'
load_test.domain_bind
'
)
}}
</h3>
...
...
@@ -7,7 +8,7 @@
</el-button>
</el-col>
</el-row>
<!-- -->
<!--
Domain name binding form
-->
<el-row>
<el-col
:span=
"24"
>
<el-table
:data=
"domains"
size=
"mini"
class=
"tb-edit"
align=
"center"
border
highlight-current-row
>
...
...
@@ -40,6 +41,7 @@
v-model=
"row.enable"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
active-value=
"readOnly"
@
click=
"confirmEdit(row)"
>
</el-switch>
...
...
frontend/src/business/components/settings/SettingMenu.vue
浏览文件 @
7f06194c
...
...
@@ -9,6 +9,7 @@
<el-menu-item
index=
"/setting/organization"
>
{{$t('commons.organization')}}
</el-menu-item>
<el-menu-item
index=
"/setting/systemworkspace"
>
{{$t('commons.workspace')}}
</el-menu-item>
<el-menu-item
index=
"/setting/testresourcepool"
>
{{$t('commons.test_resource_pool')}}
</el-menu-item>
<el-menu-item
index=
"/setting/systemparametersetting"
>
{{$t('commons.system_parameter_setting')}}
</el-menu-item>
</el-submenu>
<el-submenu
index=
"2"
v-permission=
"['org_admin']"
v-if=
"isCurrentOrganizationAdmin"
>
...
...
frontend/src/business/components/settings/system/SystemParameterSetting.vue
0 → 100644
浏览文件 @
7f06194c
<
template
>
<div>
<el-card
class=
"box-card"
v-loading=
"result.loading"
>
<template
v-slot:header
>
<h2>
{{
$t
(
'
system_parameter_setting.mailbox_service_settings
'
)
}}
</h2>
</
template
>
<!--邮件表单-->
<el-form
:inline=
"true"
:model=
"formInline"
:rules=
"rules"
ref=
"formInline"
class=
"demo-form-inline"
:disabled=
"show"
v-loading=
"loading"
>
<el-row>
<el-col>
<el-form-item
:label=
"$t('system_parameter_setting.SMTP_host')"
prop=
"host"
>
</el-form-item>
<el-input
v-model=
"formInline.host"
:placeholder=
"$t('system_parameter_setting.SMTP_host')"
v-on:input=
"host"
></el-input>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item
:label=
"$t('system_parameter_setting.SMTP_port')"
prop=
"port"
>
</el-form-item>
<el-input
v-model=
"formInline.port"
:placeholder=
"$t('system_parameter_setting.SMTP_port')"
v-on:input=
"port"
></el-input>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item
:label=
"$t('system_parameter_setting.SMTP_account')"
prop=
"account"
>
</el-form-item>
<el-input
v-model=
"formInline.account"
:placeholder=
"$t('system_parameter_setting.SMTP_account')"
v-on:input=
"account"
></el-input>
</el-col>
</el-row>
<el-row>
<el-col>
<el-form-item
:label=
"$t('system_parameter_setting.SMTP_password')"
prop=
"password"
>
</el-form-item>
<el-input
v-model=
"formInline.password"
:placeholder=
"$t('system_parameter_setting.SMTP_password')"
show-password
></el-input>
</el-col>
</el-row>
<!---->
<div
style=
"border: 0px;margin-bottom: 20px;margin-top: 20px"
>
<el-checkbox
v-model=
"SSL"
label=
"开启SSL(如果SMTP端口是465,通常需要启用SSL)"
></el-checkbox>
</div>
<div
style=
"border: 0px;margin-bottom: 20px"
>
<el-checkbox
v-model=
"TLS"
label=
"开启TLS(如果SMTP端口是587,通常需要启用TLS)"
></el-checkbox>
</div>
<div
style=
"border: 0px;margin-bottom: 20px"
>
<el-checkbox
v-model=
"SMTP"
label=
"是否匿名 SMTP"
></el-checkbox>
</div>
<
template
v-slot:footer
>
</
template
>
</el-form>
<div
style=
"margin-left: 640px"
>
<el-button
type=
"primary"
@
click=
"testConnection('formInline')"
:disabled=
"disabledConnection"
>
{{$t('system_parameter_setting.test_connection')}}
</el-button>
<el-button
@
click=
"edit"
v-if=
"showEdit"
>
{{$t('commons.edit')}}
</el-button>
<el-button
type=
"success"
@
click=
"save('formInline')"
v-if=
"showSave"
:disabled=
"disabledSave"
>
{{$t('commons.save')}}
</el-button>
<el-button
@
click=
"cancel"
type=
"info"
v-if=
"showCancel"
>
{{$t('commons.cancel')}}
</el-button>
</div>
</el-card>
</div>
</template>
<
script
>
export
default
{
name
:
"
SystemParameterSetting
"
,
data
()
{
return
{
formInline
:
{
host
:
'
smtp.163.com
'
,
port
:
'
465
'
,
account
:
'
xjj0608@153.com
'
,
password
:
'
2345678
'
,
},
result
:
{},
SSL
:
false
,
TLS
:
false
,
SMTP
:
true
,
showEdit
:
true
,
showSave
:
false
,
showCancel
:
false
,
show
:
true
,
disabledConnection
:
false
,
disabledSave
:
false
,
loading
:
false
,
rules
:
{
host
:
[
{
required
:
true
,
message
:
this
.
$t
(
'
commons.host_cannot_be_empty
'
)
},
],
port
:
[
{
required
:
true
,
message
:
'
'
}
],
account
:
[
{
required
:
true
,
message
:
'
'
}]
}
}
},
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
)
{
this
.
disabledConnection
=
true
;
this
.
disabledSave
=
true
;
}
else
{
this
.
disabledConnection
=
false
;
this
.
disabledSave
=
false
;
}
},
testConnection
(
formInline
)
{
let
param
=
{
"
meter.host
"
:
this
.
formInline
.
host
,
"
meter.port
"
:
this
.
formInline
.
port
,
"
meter.account
"
:
this
.
formInline
.
account
,
"
meter.password
"
:
this
.
formInline
.
password
,
"
meter.ssl
"
:
this
.
SSL
,
"
meter.tls
"
:
this
.
TLS
,
"
meter.smtp
"
:
this
.
SMTP
,
};
this
.
$refs
[
formInline
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
result
=
this
.
$post
(
"
/system/testConnection
"
,
param
,
response
=>
{
let
flag
=
response
.
success
;
if
(
flag
)
{
this
.
$success
(
this
.
$t
(
'
commons.connection_successful
'
));
}
else
{
this
.
$message
.
error
(
this
.
$t
(
'
commons.connection_failed
'
));
}
});
}
else
{
return
false
;
}
})
},
edit
()
{
this
.
showEdit
=
false
;
this
.
showSave
=
true
;
this
.
showCancel
=
true
;
this
.
show
=
false
;
},
save
(
formInline
)
{
this
.
showEdit
=
true
;
this
.
showCancel
=
false
;
this
.
showSave
=
false
;
this
.
show
=
true
;
let
param
=
[
{
paramKey
:
"
meter.host
"
,
paramValue
:
this
.
formInline
.
host
,
type
:
"
text
"
,
sort
:
1
},
{
paramKey
:
"
meter.port
"
,
paramValue
:
this
.
formInline
.
port
,
type
:
"
text
"
,
sort
:
2
},
{
paramKey
:
"
meter.account
"
,
paramValue
:
this
.
formInline
.
account
,
type
:
"
text
"
,
sort
:
3
},
{
paramKey
:
"
meter.password
"
,
paramValue
:
this
.
formInline
.
password
,
type
:
"
password
"
,
sort
:
4
},
{
paramKey
:
"
meter.ssl
"
,
paramValue
:
this
.
SSL
,
type
:
"
text
"
,
sort
:
5
},
{
paramKey
:
"
meter.tls
"
,
paramValue
:
this
.
TLS
,
type
:
"
text
"
,
sort
:
6
},
{
paramKey
:
"
meter.smtp
"
,
paramValue
:
this
.
SMTP
,
type
:
"
text
"
,
sort
:
7
}
]
this
.
$refs
[
formInline
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
result
=
this
.
$post
(
"
/system/edit/email
"
,
param
,
response
=>
{
let
flag
=
response
.
success
;
if
(
flag
)
{
this
.
$success
(
this
.
$t
(
'
commons.save_success
'
));
}
else
{
this
.
$message
.
error
(
this
.
$t
(
'
commons.save_failed
'
));
}
});
}
else
{
return
false
;
}
})
},
cancel
()
{
this
.
showEdit
=
true
;
this
.
showCancel
=
false
;
this
.
showSave
=
false
;
this
.
show
=
true
;
}
}
}
</
script
>
<
style
scoped
>
.text
{
font-size
:
18px
;
}
.item
{
margin-bottom
:
30px
;
}
.box-card
{
padding-left
:
5px
;
}
/
deep
/
.el-input__inner
{
border-width
:
0px
;
border-bottom-width
:
1px
;
}
</
style
>
frontend/src/i18n/en-US.js
浏览文件 @
7f06194c
...
...
@@ -57,6 +57,14 @@ export default {
'
exit_system
'
:
'
Exit System
'
,
'
verification
'
:
'
Verification
'
,
'
set_admin
'
:
'
Set Admin
'
,
'
system_parameter_setting
'
:
'
System Parameter Setting
'
,
'
connection_successful
'
:
'
Connection successful
'
,
'
connection_failed
'
:
'
Connection failed
'
,
'
save_failed
'
:
'
Saved failed
'
,
'
host_cannot_be_empty
'
:
'
Host cannot be empty
'
,
'
port_cannot_be_empty
'
:
'
Port cannot be empty
'
,
'
account_cannot_be_empty
'
:
'
Account cannot be empty
'
,
},
workspace
:
{
'
create
'
:
'
Create Workspace
'
,
...
...
@@ -422,6 +430,14 @@ export default {
'
status_change_success
'
:
'
Successfully changed the status!
'
,
'
status_change_failed
'
:
'
Failed to change the status, resource pool is invalid!
'
,
},
system_parameter_setting
:
{
'
mailbox_service_settings
'
:
'
Mailbox Service Settings
'
,
'
test_connection
'
:
'
Test connection
'
,
'
SMTP_host
'
:
'
SMTP host
'
,
'
SMTP_port
'
:
'
SMTP port
'
,
'
SMTP_account
'
:
'
SMTP account
'
,
'
SMTP_password
'
:
'
SMTP password
'
,
},
i18n
:
{
'
home
'
:
'
Home
'
}
...
...
frontend/src/i18n/zh-CN.js
浏览文件 @
7f06194c
...
...
@@ -57,6 +57,13 @@ export default {
'
exit_system
'
:
'
退出系统
'
,
'
verification
'
:
'
验证
'
,
'
set_admin
'
:
'
设置为管理员
'
,
'
system_parameter_setting
'
:
'
系统参数设置
'
,
'
connection_successful
'
:
'
连接成功
'
,
'
connection_failed
'
:
'
连接失败
'
,
'
save_failed
'
:
'
保存失败
'
,
'
host_cannot_be_empty
'
:
'
主机不能为空
'
,
'
port_cannot_be_empty
'
:
'
端口号不能为空
'
,
'
account_cannot_be_empty
'
:
'
帐户不能为空
'
,
},
workspace
:
{
'
create
'
:
'
创建工作空间
'
,
...
...
@@ -422,6 +429,14 @@ export default {
'
status_change_success
'
:
'
状态修改成功!
'
,
'
status_change_failed
'
:
'
状态修改失败, 校验不通过!
'
,
},
system_parameter_setting
:
{
'
mailbox_service_settings
'
:
'
邮件服务设置
'
,
'
test_connection
'
:
'
测试连接
'
,
'
SMTP_host
'
:
'
SMTP主机
'
,
'
SMTP_port
'
:
'
SMTP端口
'
,
'
SMTP_account
'
:
'
SMTP账户
'
,
'
SMTP_password
'
:
'
SMTP密码
'
,
},
i18n
:
{
'
home
'
:
'
首页
'
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录