Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
5ae9f9a2
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 搜索 >>
提交
5ae9f9a2
编写于
9月 27, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 重构邮件通知部分
上级
22b0a423
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
146 addition
and
41 deletion
+146
-41
backend/src/main/java/io/metersphere/base/domain/Notice.java
backend/src/main/java/io/metersphere/base/domain/Notice.java
+2
-0
backend/src/main/java/io/metersphere/base/domain/NoticeExample.java
...c/main/java/io/metersphere/base/domain/NoticeExample.java
+70
-0
backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.xml
...src/main/java/io/metersphere/base/mapper/NoticeMapper.xml
+28
-13
backend/src/main/java/io/metersphere/notice/service/MailService.java
.../main/java/io/metersphere/notice/service/MailService.java
+2
-2
backend/src/main/java/io/metersphere/notice/service/NoticeService.java
...ain/java/io/metersphere/notice/service/NoticeService.java
+6
-3
backend/src/main/resources/db/migration/V26__modify_notice.sql
...nd/src/main/resources/db/migration/V26__modify_notice.sql
+2
-0
frontend/src/business/components/common/components/MsScheduleEdit.vue
.../business/components/common/components/MsScheduleEdit.vue
+29
-22
frontend/src/business/components/xpack
frontend/src/business/components/xpack
+1
-1
frontend/src/i18n/en-US.js
frontend/src/i18n/en-US.js
+2
-0
frontend/src/i18n/zh-CN.js
frontend/src/i18n/zh-CN.js
+2
-0
frontend/src/i18n/zh-TW.js
frontend/src/i18n/zh-TW.js
+2
-0
未找到文件。
backend/src/main/java/io/metersphere/base/domain/Notice.java
浏览文件 @
5ae9f9a2
...
...
@@ -16,5 +16,7 @@ public class Notice implements Serializable {
private
String
enable
;
private
String
type
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
backend/src/main/java/io/metersphere/base/domain/NoticeExample.java
浏览文件 @
5ae9f9a2
...
...
@@ -453,6 +453,76 @@ public class NoticeExample {
addCriterion
(
"`ENABLE` not between"
,
value1
,
value2
,
"enable"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIsNull
()
{
addCriterion
(
"`type` is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIsNotNull
()
{
addCriterion
(
"`type` is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeEqualTo
(
String
value
)
{
addCriterion
(
"`type` ="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotEqualTo
(
String
value
)
{
addCriterion
(
"`type` <>"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeGreaterThan
(
String
value
)
{
addCriterion
(
"`type` >"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"`type` >="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLessThan
(
String
value
)
{
addCriterion
(
"`type` <"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"`type` <="
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeLike
(
String
value
)
{
addCriterion
(
"`type` like"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotLike
(
String
value
)
{
addCriterion
(
"`type` not like"
,
value
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeIn
(
List
<
String
>
values
)
{
addCriterion
(
"`type` in"
,
values
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"`type` not in"
,
values
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"`type` between"
,
value1
,
value2
,
"type"
);
return
(
Criteria
)
this
;
}
public
Criteria
andTypeNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"`type` not between"
,
value1
,
value2
,
"type"
);
return
(
Criteria
)
this
;
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
...
...
backend/src/main/java/io/metersphere/base/mapper/NoticeMapper.xml
浏览文件 @
5ae9f9a2
...
...
@@ -7,6 +7,7 @@
<result
column=
"TEST_ID"
jdbcType=
"VARCHAR"
property=
"testId"
/>
<result
column=
"NAME"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"ENABLE"
jdbcType=
"VARCHAR"
property=
"enable"
/>
<result
column=
"type"
jdbcType=
"VARCHAR"
property=
"type"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
...
...
@@ -67,7 +68,7 @@
</where>
</sql>
<sql
id=
"Base_Column_List"
>
id, EVENT, TEST_ID, `NAME`, `ENABLE`
id, EVENT, TEST_ID, `NAME`, `ENABLE`
, `type`
</sql>
<select
id=
"selectByExample"
parameterType=
"io.metersphere.base.domain.NoticeExample"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -84,26 +85,26 @@
</if>
</select>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.String"
resultMap=
"BaseResultMap"
>
SELECT
select
<include
refid=
"Base_Column_List"
/>
FROM
notice
WHERE
id = #{id,jdbcType=VARCHAR}
from
notice
where
id = #{id,jdbcType=VARCHAR}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.String"
>
DELETE FROM notice
WHERE id = #{id,jdbcType=VARCHAR}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"io.metersphere.base.domain.NoticeExample"
>
DELETE FROM
notice
delete from
notice
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"io.metersphere.base.domain.Notice"
>
INSERT INTO notice (id, EVENT, TEST_ID,
`NAME`, `ENABLE`)
`NAME`, `ENABLE`
, `type`
)
VALUES (#{id,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{enable,jdbcType=VARCHAR})
#{name,jdbcType=VARCHAR}, #{enable,jdbcType=VARCHAR}
, #{type,jdbcType=VARCHAR}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"io.metersphere.base.domain.Notice"
>
insert into notice
...
...
@@ -123,6 +124,9 @@
<if
test=
"enable != null"
>
`ENABLE`,
</if>
<if
test=
"type != null"
>
`type`,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
...
...
@@ -140,6 +144,9 @@
<if
test=
"enable != null"
>
#{enable,jdbcType=VARCHAR},
</if>
<if
test=
"type != null"
>
#{type,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"io.metersphere.base.domain.NoticeExample"
resultType=
"java.lang.Long"
>
...
...
@@ -166,24 +173,28 @@
<if
test=
"record.enable != null"
>
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
</if>
<if
test=
"record.type != null"
>
`type` = #{record.type,jdbcType=VARCHAR},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
UPDATE
notice
SET
id = #{record.id,jdbcType=VARCHAR},
update
notice
set
id = #{record.id,jdbcType=VARCHAR},
EVENT = #{record.event,jdbcType=VARCHAR},
TEST_ID = #{record.testId,jdbcType=VARCHAR},
`NAME` = #{record.name,jdbcType=VARCHAR},
`ENABLE` = #{record.enable,jdbcType=VARCHAR}
`ENABLE` = #{record.enable,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"io.metersphere.base.domain.Notice"
>
UPDATE
notice
update
notice
<set>
<if
test=
"event != null"
>
EVENT = #{event,jdbcType=VARCHAR},
...
...
@@ -197,15 +208,19 @@
<if
test=
"enable != null"
>
`ENABLE` = #{enable,jdbcType=VARCHAR},
</if>
<if
test=
"type != null"
>
`type` = #{type,jdbcType=VARCHAR},
</if>
</set>
WHERE
id = #{id,jdbcType=VARCHAR}
where
id = #{id,jdbcType=VARCHAR}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"io.metersphere.base.domain.Notice"
>
UPDATE notice
SET EVENT = #{event,jdbcType=VARCHAR},
TEST_ID = #{testId,jdbcType=VARCHAR},
`NAME` = #{name,jdbcType=VARCHAR},
`ENABLE` = #{enable,jdbcType=VARCHAR}
`ENABLE` = #{enable,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR}
WHERE id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
backend/src/main/java/io/metersphere/notice/service/MailService.java
浏览文件 @
5ae9f9a2
...
...
@@ -222,10 +222,10 @@ public class MailService {
List
<
String
>
failEmailList
=
new
ArrayList
<>();
if
(
noticeList
.
size
()
>
0
)
{
for
(
NoticeDetail
n
:
noticeList
)
{
if
(
n
.
getEnable
().
equals
(
"true"
)
&&
n
.
getEvent
().
equals
(
"
执行成功
"
))
{
if
(
n
.
getEnable
().
equals
(
"true"
)
&&
n
.
getEvent
().
equals
(
"
EXECUTE_SUCCESSFUL
"
))
{
successEmailList
=
userService
.
queryEmail
(
n
.
getNames
());
}
if
(
n
.
getEnable
().
equals
(
"true"
)
&&
n
.
getEvent
().
equals
(
"
执行失败
"
))
{
if
(
n
.
getEnable
().
equals
(
"true"
)
&&
n
.
getEvent
().
equals
(
"
EXECUTE_FAILED
"
))
{
failEmailList
=
userService
.
queryEmail
(
n
.
getNames
());
}
}
...
...
backend/src/main/java/io/metersphere/notice/service/NoticeService.java
浏览文件 @
5ae9f9a2
...
...
@@ -18,7 +18,6 @@ public class NoticeService {
private
NoticeMapper
noticeMapper
;
public
void
saveNotice
(
NoticeRequest
noticeRequest
)
{
Notice
notice
=
new
Notice
();
NoticeExample
example
=
new
NoticeExample
();
example
.
createCriteria
().
andTestIdEqualTo
(
noticeRequest
.
getTestId
());
List
<
Notice
>
notices
=
noticeMapper
.
selectByExample
(
example
);
...
...
@@ -28,11 +27,13 @@ public class NoticeService {
noticeRequest
.
getNotices
().
forEach
(
n
->
{
if
(
n
.
getNames
().
length
>
0
)
{
for
(
String
x
:
n
.
getNames
())
{
Notice
notice
=
new
Notice
();
notice
.
setId
(
UUID
.
randomUUID
().
toString
());
notice
.
setEvent
(
n
.
getEvent
());
notice
.
setEnable
(
n
.
getEnable
());
notice
.
setTestId
(
noticeRequest
.
getTestId
());
notice
.
setName
(
x
);
notice
.
setType
(
n
.
getType
());
noticeMapper
.
insert
(
notice
);
}
}
...
...
@@ -52,16 +53,18 @@ public class NoticeService {
NoticeDetail
notice2
=
new
NoticeDetail
();
if
(
notices
.
size
()
>
0
)
{
for
(
Notice
n
:
notices
)
{
if
(
n
.
getEvent
().
equals
(
"
执行成功
"
))
{
if
(
n
.
getEvent
().
equals
(
"
EXECUTE_SUCCESSFUL
"
))
{
success
.
add
(
n
.
getName
());
notice1
.
setEnable
(
n
.
getEnable
());
notice1
.
setTestId
(
id
);
notice1
.
setType
(
n
.
getType
());
notice1
.
setEvent
(
n
.
getEvent
());
}
if
(
n
.
getEvent
().
equals
(
"
执行失败
"
))
{
if
(
n
.
getEvent
().
equals
(
"
EXECUTE_FAILED
"
))
{
fail
.
add
(
n
.
getName
());
notice2
.
setEnable
(
n
.
getEnable
());
notice2
.
setTestId
(
id
);
notice2
.
setType
(
n
.
getType
());
notice2
.
setEvent
(
n
.
getEvent
());
}
}
...
...
backend/src/main/resources/db/migration/V26__modify_notice.sql
浏览文件 @
5ae9f9a2
...
...
@@ -6,3 +6,5 @@ ALTER TABLE notice
MODIFY
COLUMN
id
VARCHAR
(
50
)
PRIMARY
KEY
;
ALTER
TABLE
notice
DROP
COLUMN
EMAIL
;
ALTER
TABLE
notice
ADD
COLUMN
type
VARCHAR
(
100
)
DEFAULT
'EMAIL'
;
\ No newline at end of file
frontend/src/business/components/common/components/MsScheduleEdit.vue
浏览文件 @
5ae9f9a2
<
template
>
<el-dialog
:close-on-click-modal=
"false"
width=
"
5
0%"
class=
"schedule-edit"
:visible.sync=
"dialogVisible"
<el-dialog
:close-on-click-modal=
"false"
width=
"
6
0%"
class=
"schedule-edit"
:visible.sync=
"dialogVisible"
@
close=
"close"
>
<template>
<div>
...
...
@@ -21,7 +21,7 @@
</el-form-item>
<crontab-result
:ex=
"form.cronValue"
ref=
"crontabResult"
/>
</el-form>
<el-dialog
:title=
"$t('schedule.generate_expression')"
:visible.sync=
"showCron"
:modal=
"false"
>
<el-dialog
width=
"60%"
:title=
"$t('schedule.generate_expression')"
:visible.sync=
"showCron"
:modal=
"false"
>
<crontab
@
hide=
"showCron=false"
@
fill=
"crontabFill"
:expression=
"schedule.value"
ref=
"crontab"
/>
</el-dialog>
</el-tab-pane>
...
...
@@ -32,9 +32,12 @@
style=
"width: 100%"
>
<el-table-column
prop=
"event"
:label=
"$t('schedule.event')"
>
:label=
"$t('schedule.event')"
>
<template
v-slot:default=
"
{row}">
<span
v-if=
"row.event === 'EXECUTE_SUCCESSFUL'"
>
{{
$t
(
'
schedule.event_success
'
)
}}
</span>
<span
v-else-if=
"row.event === 'EXECUTE_FAILED'"
>
{{
$t
(
'
schedule.event_failed
'
)
}}
</span>
<span
v-else
>
{{
row
.
event
}}
</span>
</
template
>
</el-table-column>
<el-table-column
prop=
"name"
...
...
@@ -42,7 +45,8 @@
width=
"200"
>
<
template
v-slot:default=
"{row}"
>
<el-select
v-model=
"row.names"
filterable
multiple
placeholder=
"请选择"
@
click.native=
"userList()"
>
<el-select
v-model=
"row.names"
filterable
multiple
:placeholder=
"$t('commons.please_select')"
@
click.native=
"userList()"
>
<el-option
v-for=
"item in options"
:key=
"item.id"
...
...
@@ -53,7 +57,7 @@
</
template
>
</el-table-column>
<el-table-column
prop=
"
email
"
prop=
"
type
"
:label=
"$t('schedule.receiving_mode')"
>
</el-table-column>
...
...
@@ -63,10 +67,10 @@
>
<
template
v-slot:default=
"{row}"
>
<el-switch
v-model=
"row.enable"
active-value=
"true"
inactive-value=
"false"
inactive-color=
"#DCDFE6"
v-model=
"row.enable"
active-value=
"true"
inactive-value=
"false"
inactive-color=
"#DCDFE6"
/>
</
template
>
</el-table-column>
...
...
@@ -142,19 +146,21 @@ export default {
},
tableData
:
[
{
event
:
"
执行成功
"
,
event
:
"
EXECUTE_SUCCESSFUL
"
,
type
:
"
EMAIL
"
,
names
:
[],
enable
:
false
},
{
event
:
"
执行失败
"
,
event
:
"
EXECUTE_FAILED
"
,
type
:
"
EMAIL
"
,
names
:
[],
enable
:
false
}
],
options
:
[{}],
enable
:
true
,
email
:
""
,
type
:
""
,
activeName
:
'
first
'
,
rules
:
{
cronValue
:
[{
required
:
true
,
validator
:
validateCron
,
trigger
:
'
blur
'
}],
...
...
@@ -168,17 +174,18 @@ export default {
})
},
handleClick
()
{
if
(
this
.
activeName
==
"
second
"
)
{
if
(
this
.
activeName
==
=
"
second
"
)
{
this
.
result
=
this
.
$get
(
'
notice/query/
'
+
this
.
testId
,
response
=>
{
if
(
response
.
data
.
length
>
0
)
{
this
.
tableData
=
response
.
data
this
.
tableData
[
0
].
email
=
"
邮箱
"
this
.
tableData
[
0
].
event
=
"
执行成功
"
this
.
tableData
[
1
].
email
=
"
邮箱
"
this
.
tableData
[
1
].
event
=
"
执行失败
"
}
else
{
this
.
tableData
[
0
].
names
=
[]
this
.
tableData
[
1
].
names
=
[]
this
.
tableData
[
0
].
event
=
"
EXECUTE_SUCCESSFUL
"
this
.
tableData
[
0
].
type
=
"
EMAIL
"
this
.
tableData
[
1
].
event
=
"
EXECUTE_FAILED
"
this
.
tableData
[
1
].
type
=
"
EMAIL
"
}
else
{
this
.
tableData
[
0
].
names
=
[]
this
.
tableData
[
1
].
names
=
[]
}
})
}
...
...
xpack
@
cc38137a
比较
06d935cd
...
cc38137a
Subproject commit
06d935cd1d22ab36f09763745c2aff8ad3fb08c1
Subproject commit
cc38137a69a0f20fadece9c0f9f50a9468c4ace9
frontend/src/i18n/en-US.js
浏览文件 @
5ae9f9a2
...
...
@@ -930,6 +930,8 @@ export default {
schedule
:
{
input_email
:
"
Please input email account
"
,
event
:
"
event
"
,
event_success
:
'
EXECUTE SUCCESSFUL
'
,
event_failed
:
'
EXECUTE FAILED
'
,
receiving_mode
:
"
mailbox
"
,
receiver
:
"
Receiver
"
,
operation
:
"
operation
"
,
...
...
frontend/src/i18n/zh-CN.js
浏览文件 @
5ae9f9a2
...
...
@@ -935,6 +935,8 @@ export default {
schedule
:
{
input_email
:
"
请输入邮箱账号
"
,
event
:
"
事件
"
,
event_success
:
'
执行成功
'
,
event_failed
:
'
执行失败
'
,
receiving_mode
:
"
接收方式
"
,
receiver
:
"
接收人
"
,
operation
:
"
操作
"
,
...
...
frontend/src/i18n/zh-TW.js
浏览文件 @
5ae9f9a2
...
...
@@ -931,6 +931,8 @@ export default {
schedule
:
{
input_email
:
"
請輸入郵箱賬號
"
,
event
:
"
事件
"
,
event_success
:
'
執行成功
'
,
event_failed
:
'
執行失敗
'
,
receiving_mode
:
"
接收方式
"
,
receiver
:
"
接收人
"
,
operation
:
"
操作
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录