refactor: 缺陷处理人接收通知 flyway 默认配置

This commit is contained in:
Captain.B 2021-08-24 15:43:08 +08:00 committed by 刘瑞斌
parent 5feb9d8c5c
commit 5868d06069
6 changed files with 128 additions and 47 deletions

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtOrganizationMapper"> <mapper namespace="io.metersphere.base.mapper.ext.ExtOrganizationMapper">
<select id="checkSourceRole" resultType="Integer"> <select id="checkSourceRole" resultType="Integer">
select count(id) SELECT COUNT(id)
from user_group ug FROM user_group ug
where ug.user_id = #{userId} WHERE ug.user_id = #{userId}
and ug.source_id = #{sourceId} AND ug.source_id = #{sourceId}
and ug.group_id = #{groupId} AND ug.group_id = #{groupId}
</select> </select>
<select id="findIdAndNameByOrganizationId" resultType="io.metersphere.dto.OrganizationMemberDTO"> <select id="findIdAndNameByOrganizationId" resultType="io.metersphere.dto.OrganizationMemberDTO">
select id,name from Organization SELECT id, name
FROM Organization
<where> <where>
<if test="organizationId != 'All'"> <if test="organizationId != 'All'">
AND id = #{organizationId} AND id = #{organizationId}
@ -108,6 +108,27 @@
#{orgId}, NULL, 1629446251939, NULL), #{orgId}, NULL, 1629446251939, NULL),
(UUID(), 'IN_SITE', 'DELETE', 'FOLLOW_PEOPLE', 'TRACK_TEST_CASE_TASK', '', (UUID(), 'IN_SITE', 'DELETE', 'FOLLOW_PEOPLE', 'TRACK_TEST_CASE_TASK', '',
'7c26254e-85e9-4269-be13-a2ffcfe0b9f5', 0, #{orgId}, NULL, 1629446251939, '7c26254e-85e9-4269-be13-a2ffcfe0b9f5', 0, #{orgId}, NULL, 1629446251939,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_SUCCESSFUL', 'CREATOR', 'API_DEFINITION_TASK', '',
'7efddbdb-2b6c-4425-96a4-0bc2aa9e2cd2', 0, #{orgId}, NULL, 1629775183917,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_FAILED', 'CREATOR', 'API_DEFINITION_TASK', '',
'e508035c-1318-40ea-9457-0bbe9865f4ce', 0, #{orgId}, NULL, 1629775194857,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_COMPLETED', 'CREATOR', 'PERFORMANCE_TEST_TASK', '',
'e3db90c6-fb49-4e89-bc25-1d14b5ce94d0', 0, #{orgId}, NULL, 1629790602744,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_FAILED', 'CREATOR', 'API_AUTOMATION_TASK', '',
'c25930e8-b617-45f7-af5e-cc94adc14192', 0, #{orgId}, NULL, 1629780485724,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_SUCCESSFUL', 'CREATOR', 'API_AUTOMATION_TASK', '',
'9f91e5e5-1744-4160-bfc6-3851bfd59e05', 0, #{orgId}, NULL, 1629780475764,
NULL),
(UUID(), 'IN_SITE', 'UPDATE', 'PROCESSOR', 'DEFECT_TASK', '',
'6cad944e-db8d-4786-9ef3-7d6370940325', 0, #{orgId}, NULL, 1629791388405,
NULL),
(UUID(), 'IN_SITE', 'CREATE', 'PROCESSOR', 'DEFECT_TASK', '',
'4a890e41-e755-44fc-b734-d6a0ca25a65c', 0, #{orgId}, NULL, 1629790487682,
NULL) NULL)
</insert> </insert>
</mapper> </mapper>

View File

@ -56,5 +56,6 @@ public interface NoticeConstants {
String EXECUTOR = "EXECUTOR";//负责人(评审人 String EXECUTOR = "EXECUTOR";//负责人(评审人
String MAINTAINER = "MAINTAINER";//维护人 String MAINTAINER = "MAINTAINER";//维护人
String FOLLOW_PEOPLE = "FOLLOW_PEOPLE";//关注人 String FOLLOW_PEOPLE = "FOLLOW_PEOPLE";//关注人
String PROCESSOR = "PROCESSOR";//关注人
} }
} }

View File

@ -1,5 +1,8 @@
package io.metersphere.notice.sender; package io.metersphere.notice.sender;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.NotificationConstants; import io.metersphere.commons.constants.NotificationConstants;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
@ -161,6 +164,18 @@ public abstract class AbstractNoticeSender implements NoticeSender {
toUsers.add(new Receiver(followPeople, NotificationConstants.Type.SYSTEM_NOTICE.name())); toUsers.add(new Receiver(followPeople, NotificationConstants.Type.SYSTEM_NOTICE.name()));
} }
break; break;
case NoticeConstants.RelatedUser.PROCESSOR:
String customFields = (String) paramMap.get("customFields");
JSONArray array = JSON.parseArray(customFields);
for (Object o : array) {
JSONObject jsonObject = JSON.parseObject(o.toString());
if (StringUtils.equals(jsonObject.getString("name"), "处理人")) {
String processor = jsonObject.getString("value");
toUsers.add(new Receiver(processor, NotificationConstants.Type.SYSTEM_NOTICE.name()));
break;
}
}
break;
default: default:
toUsers.add(new Receiver(userId, NotificationConstants.Type.MENTIONED_ME.name())); toUsers.add(new Receiver(userId, NotificationConstants.Type.MENTIONED_ME.name()));
break; break;

View File

@ -87,7 +87,7 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent {
.testId(loadTestReport.getTestId()) .testId(loadTestReport.getTestId())
.status(loadTestReport.getStatus()) .status(loadTestReport.getStatus())
.subject(subject) .subject(subject)
.event(event) .event(NoticeConstants.Event.EXECUTE_COMPLETED)
.paramMap(paramMap) .paramMap(paramMap)
.build(); .build();
noticeSendService.send(organization, NoticeConstants.TaskType.PERFORMANCE_TEST_TASK, noticeModel2); noticeSendService.send(organization, NoticeConstants.TaskType.PERFORMANCE_TEST_TASK, noticeModel2);

View File

@ -87,21 +87,28 @@ ALTER TABLE `project`
ALTER TABLE `api_scenario` ALTER TABLE `api_scenario`
ADD `execute_times` int(11) NULL; ADD `execute_times` int(11) NULL;
ALTER TABLE `api_scenario_report` ADD `end_time` bigint(13) ; ALTER TABLE `api_scenario_report`
ADD `end_time` bigint(13);
-- 修改文档分享表 -- 修改文档分享表
ALTER TABLE api_document_share RENAME TO share_info; ALTER TABLE api_document_share RENAME TO share_info;
ALTER TABLE share_info change ALTER TABLE share_info
column share_api_id custom_data longtext CHARACTER CHANGE
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Share Custom Data'; COLUMN share_api_id custom_data longtext CHARACTER
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Share Custom Data';
ALTER TABLE test_plan ADD report_config text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '测试计划报告配置'; ALTER TABLE test_plan
ADD report_config text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '测试计划报告配置';
-- 删除不用的记录表 -- 删除不用的记录表
DROP TABLE test_plan_report_resource; DROP TABLE test_plan_report_resource;
-- 统一接口案例未执行的状态字段 -- 统一接口案例未执行的状态字段
update api_test_case SET `status` = '' WHERE `status` = 'Underway'; UPDATE api_test_case
update api_test_case SET `original_status` = '' WHERE `original_status` = 'Underway'; SET `status` = ''
WHERE `status` = 'Underway';
UPDATE api_test_case
SET `original_status` = ''
WHERE `original_status` = 'Underway';
-- 设置默认的通知 -- 设置默认的通知
@ -213,6 +220,27 @@ BEGIN
orgId, NULL, 1629446251939, NULL), orgId, NULL, 1629446251939, NULL),
(UUID(), 'IN_SITE', 'DELETE', 'FOLLOW_PEOPLE', 'TRACK_TEST_CASE_TASK', '', (UUID(), 'IN_SITE', 'DELETE', 'FOLLOW_PEOPLE', 'TRACK_TEST_CASE_TASK', '',
'7c26254e-85e9-4269-be13-a2ffcfe0b9f5', 0, orgId, NULL, 1629446251939, '7c26254e-85e9-4269-be13-a2ffcfe0b9f5', 0, orgId, NULL, 1629446251939,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_SUCCESSFUL', 'CREATOR', 'API_DEFINITION_TASK', '',
'7efddbdb-2b6c-4425-96a4-0bc2aa9e2cd2', 0, orgId, NULL, 1629775183917,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_FAILED', 'CREATOR', 'API_DEFINITION_TASK', '',
'e508035c-1318-40ea-9457-0bbe9865f4ce', 0, orgId, NULL, 1629775194857,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_COMPLETED', 'CREATOR', 'PERFORMANCE_TEST_TASK', '',
'e3db90c6-fb49-4e89-bc25-1d14b5ce94d0', 0, orgId, NULL, 1629790602744,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_FAILED', 'CREATOR', 'API_AUTOMATION_TASK', '',
'c25930e8-b617-45f7-af5e-cc94adc14192', 0, orgId, NULL, 1629780485724,
NULL),
(UUID(), 'IN_SITE', 'EXECUTE_SUCCESSFUL', 'CREATOR', 'API_AUTOMATION_TASK', '',
'9f91e5e5-1744-4160-bfc6-3851bfd59e05', 0, orgId, NULL, 1629780475764,
NULL),
(uuid(), 'IN_SITE', 'UPDATE', 'PROCESSOR', 'DEFECT_TASK', '',
'6cad944e-db8d-4786-9ef3-7d6370940325', 0, orgId, NULL, 1629791388405,
NULL),
(uuid(), 'IN_SITE', 'CREATE', 'PROCESSOR', 'DEFECT_TASK', '',
'4a890e41-e755-44fc-b734-d6a0ca25a65c', 0, orgId, NULL, 1629790487682,
NULL); NULL);
-- --
@ -227,43 +255,50 @@ DROP PROCEDURE IF EXISTS set_notice;
-- 保存测试报告 -- 保存测试报告
ALTER TABLE test_plan_report ADD is_new TINYINT(1) NULL COMMENT 'v1.12报告改版标记'; ALTER TABLE test_plan_report
ALTER table test_plan_report modify `is_api_case_executing` TINYINT(1) NULL COMMENT 'is Api Case executing'; ADD is_new TINYINT(1) NULL COMMENT 'v1.12报告改版标记';
ALTER table test_plan_report modify `is_scenario_executing` TINYINT(1) NULL COMMENT 'is scenario Case executing'; ALTER TABLE test_plan_report
ALTER table test_plan_report modify `is_performance_executing` TINYINT(1) NULL COMMENT 'is performance executing'; MODIFY `is_api_case_executing` TINYINT(1) NULL COMMENT 'is Api Case executing';
CREATE TABLE IF NOT EXISTS `test_plan_report_content` ( ALTER TABLE test_plan_report
`id` VARCHAR (50) NOT NULL COMMENT 'ID', MODIFY `is_scenario_executing` TINYINT(1) NULL COMMENT 'is scenario Case executing';
`test_plan_report_id` VARCHAR ( 50 ) NOT NULL COMMENT 'Test plan ID', ALTER TABLE test_plan_report
`start_time` bigint(13) NULL, MODIFY `is_performance_executing` TINYINT(1) NULL COMMENT 'is performance executing';
`case_count` bigint(10) NULL, CREATE TABLE IF NOT EXISTS `test_plan_report_content`
`end_time` bigint(13) NULL, (
`execute_rate` DOUBLE NULL, `id` VARCHAR(50) NOT NULL COMMENT 'ID',
`pass_rate` DOUBLE NULL, `test_plan_report_id` VARCHAR(50) NOT NULL COMMENT 'Test plan ID',
`is_third_part_issue` TINYINT(1) NULL COMMENT 'is third part issue', `start_time` bigint(13) NULL,
`case_count` bigint(10) NULL,
`end_time` bigint(13) NULL,
`execute_rate` DOUBLE NULL,
`pass_rate` DOUBLE NULL,
`is_third_part_issue` TINYINT(1) NULL COMMENT 'is third part issue',
`config` text COMMENT 'plan config (JSON format)', `config` text COMMENT 'plan config (JSON format)',
`summary` text COMMENT 'summary', `summary` text COMMENT 'summary',
`function_result` text COMMENT 'function result (JSON format)', `function_result` text COMMENT 'function result (JSON format)',
`api_result` text COMMENT 'api result (JSON format)', `api_result` text COMMENT 'api result (JSON format)',
`load_result` text COMMENT 'api result (JSON format)', `load_result` text COMMENT 'api result (JSON format)',
`function_all_cases` longtext COMMENT 'function all cases (JSON format)', `function_all_cases` longtext COMMENT 'function all cases (JSON format)',
`function_failure_cases` longtext COMMENT 'function failure cases (JSON format)', `function_failure_cases` longtext COMMENT 'function failure cases (JSON format)',
`issue_list` longtext COMMENT 'issue list (JSON format)', `issue_list` longtext COMMENT 'issue list (JSON format)',
`api_all_cases` longtext COMMENT 'api all cases (JSON format)', `api_all_cases` longtext COMMENT 'api all cases (JSON format)',
`api_failure_cases` longtext COMMENT 'api failure cases (JSON format)', `api_failure_cases` longtext COMMENT 'api failure cases (JSON format)',
`scenario_all_cases` longtext COMMENT 'scenario all cases (JSON format)', `scenario_all_cases` longtext COMMENT 'scenario all cases (JSON format)',
`scenario_failure_cases` longtext COMMENT 'scenario failure cases (JSON format)', `scenario_failure_cases` longtext COMMENT 'scenario failure cases (JSON format)',
`load_all_Cases` longtext COMMENT 'load all cases (JSON format)', `load_all_Cases` longtext COMMENT 'load all cases (JSON format)',
`load_failure_cases` longtext COMMENT 'load failure cases (JSON format)', `load_failure_cases` longtext COMMENT 'load failure cases (JSON format)',
PRIMARY KEY ( `id` ), PRIMARY KEY (`id`),
UNIQUE KEY `test_plan_report_id` ( `test_plan_report_id` ) UNIQUE KEY `test_plan_report_id` (`test_plan_report_id`)
) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci; ) ENGINE = INNODB
DEFAULT CHARSET = utf8mb4
COLLATE utf8mb4_general_ci;
# 复制测试计划权限 # 复制测试计划权限

View File

@ -195,7 +195,6 @@ export default {
{value: 'CREATE', label: this.$t('commons.create')}, {value: 'CREATE', label: this.$t('commons.create')},
{value: 'UPDATE', label: this.$t('commons.update')}, {value: 'UPDATE', label: this.$t('commons.update')},
{value: 'DELETE', label: this.$t('commons.delete')}, {value: 'DELETE', label: this.$t('commons.delete')},
// {value: 'STATUS_CHANGE', label: ''},
], ],
}; };
}, },
@ -287,20 +286,30 @@ export default {
}, },
handleReceivers(row) { handleReceivers(row) {
let testPlanReceivers = JSON.parse(JSON.stringify(this.defectReceiverOptions)); let testPlanReceivers = JSON.parse(JSON.stringify(this.defectReceiverOptions));
let i = row.userIds.indexOf('PROCESSOR');
let i2 = row.userIds.indexOf('CREATOR'); let i2 = row.userIds.indexOf('CREATOR');
switch (row.event) { switch (row.event) {
case "CREATE": case "CREATE":
testPlanReceivers.unshift({id: 'PROCESSOR', name: '处理人'});
if (row.isSet) {
if (i < 0) {
row.userIds.unshift('PROCESSOR');
}
}
if (i2 > -1) { if (i2 > -1) {
row.userIds.splice(i2, 1); row.userIds.splice(i2, 1);
} }
break; break;
case "UPDATE": case "UPDATE":
case "STATUS_CHANGE":
testPlanReceivers.unshift({id: 'CREATOR', name: this.$t('commons.create_user')}); testPlanReceivers.unshift({id: 'CREATOR', name: this.$t('commons.create_user')});
testPlanReceivers.unshift({id: 'PROCESSOR', name: '处理人'});
if (row.isSet) { if (row.isSet) {
if (i2 < 0) { if (i2 < 0) {
row.userIds.unshift('CREATOR'); row.userIds.unshift('CREATOR');
} }
if (i < 0) {
row.userIds.unshift('PROCESSOR');
}
} }
break; break;
case "DELETE": case "DELETE":