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" ?>
<!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">
<select id="checkSourceRole" resultType="Integer">
select count(id)
from user_group ug
where ug.user_id = #{userId}
and ug.source_id = #{sourceId}
and ug.group_id = #{groupId}
SELECT COUNT(id)
FROM user_group ug
WHERE ug.user_id = #{userId}
AND ug.source_id = #{sourceId}
AND ug.group_id = #{groupId}
</select>
<select id="findIdAndNameByOrganizationId" resultType="io.metersphere.dto.OrganizationMemberDTO">
select id,name from Organization
SELECT id, name
FROM Organization
<where>
<if test="organizationId != 'All'">
AND id = #{organizationId}
@ -108,6 +108,27 @@
#{orgId}, NULL, 1629446251939, NULL),
(UUID(), 'IN_SITE', 'DELETE', 'FOLLOW_PEOPLE', 'TRACK_TEST_CASE_TASK', '',
'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)
</insert>
</mapper>

View File

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

View File

@ -1,5 +1,8 @@
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.NotificationConstants;
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()));
}
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:
toUsers.add(new Receiver(userId, NotificationConstants.Type.MENTIONED_ME.name()));
break;

View File

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

View File

@ -87,21 +87,28 @@ ALTER TABLE `project`
ALTER TABLE `api_scenario`
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 share_info change
column share_api_id custom_data longtext CHARACTER
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Share Custom Data';
ALTER TABLE share_info
CHANGE
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;
-- 统一接口案例未执行的状态字段
update api_test_case SET `status` = '' WHERE `status` = 'Underway';
update api_test_case SET `original_status` = '' WHERE `original_status` = 'Underway';
UPDATE api_test_case
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),
(UUID(), 'IN_SITE', 'DELETE', 'FOLLOW_PEOPLE', 'TRACK_TEST_CASE_TASK', '',
'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);
--
@ -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 modify `is_api_case_executing` TINYINT(1) NULL COMMENT 'is Api Case executing';
ALTER table test_plan_report modify `is_scenario_executing` TINYINT(1) NULL COMMENT 'is scenario Case executing';
ALTER table test_plan_report modify `is_performance_executing` TINYINT(1) NULL COMMENT 'is performance executing';
CREATE TABLE IF NOT EXISTS `test_plan_report_content` (
`id` VARCHAR (50) NOT NULL COMMENT 'ID',
`test_plan_report_id` VARCHAR ( 50 ) NOT NULL COMMENT 'Test plan ID',
`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',
ALTER TABLE test_plan_report
ADD is_new TINYINT(1) NULL COMMENT 'v1.12报告改版标记';
ALTER TABLE test_plan_report
MODIFY `is_api_case_executing` TINYINT(1) NULL COMMENT 'is Api Case executing';
ALTER TABLE test_plan_report
MODIFY `is_scenario_executing` TINYINT(1) NULL COMMENT 'is scenario Case executing';
ALTER TABLE test_plan_report
MODIFY `is_performance_executing` TINYINT(1) NULL COMMENT 'is performance executing';
CREATE TABLE IF NOT EXISTS `test_plan_report_content`
(
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
`test_plan_report_id` VARCHAR(50) NOT NULL COMMENT 'Test plan ID',
`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)',
`summary` text COMMENT 'summary',
`config` text COMMENT 'plan config (JSON format)',
`summary` text COMMENT 'summary',
`function_result` text COMMENT 'function result (JSON format)',
`api_result` text COMMENT 'api result (JSON format)',
`load_result` text COMMENT 'api result (JSON format)',
`function_result` text COMMENT 'function result (JSON format)',
`api_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_failure_cases` longtext COMMENT 'function failure cases (JSON format)',
`issue_list` longtext COMMENT 'issue list (JSON format)',
`function_all_cases` longtext COMMENT 'function all cases (JSON format)',
`function_failure_cases` longtext COMMENT 'function failure cases (JSON format)',
`issue_list` longtext COMMENT 'issue list (JSON format)',
`api_all_cases` longtext COMMENT 'api all cases (JSON format)',
`api_failure_cases` longtext COMMENT 'api failure cases (JSON format)',
`api_all_cases` longtext COMMENT 'api all cases (JSON format)',
`api_failure_cases` longtext COMMENT 'api failure cases (JSON format)',
`scenario_all_cases` longtext COMMENT 'scenario all cases (JSON format)',
`scenario_failure_cases` longtext COMMENT 'scenario failure cases (JSON format)',
`scenario_all_cases` longtext COMMENT 'scenario all cases (JSON format)',
`scenario_failure_cases` longtext COMMENT 'scenario failure cases (JSON format)',
`load_all_Cases` longtext COMMENT 'load all cases (JSON format)',
`load_failure_cases` longtext COMMENT 'load failure cases (JSON format)',
`load_all_Cases` longtext COMMENT 'load all cases (JSON format)',
`load_failure_cases` longtext COMMENT 'load failure cases (JSON format)',
PRIMARY KEY ( `id` ),
UNIQUE KEY `test_plan_report_id` ( `test_plan_report_id` )
) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci;
PRIMARY KEY (`id`),
UNIQUE KEY `test_plan_report_id` (`test_plan_report_id`)
) 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: 'UPDATE', label: this.$t('commons.update')},
{value: 'DELETE', label: this.$t('commons.delete')},
// {value: 'STATUS_CHANGE', label: ''},
],
};
},
@ -287,20 +286,30 @@ export default {
},
handleReceivers(row) {
let testPlanReceivers = JSON.parse(JSON.stringify(this.defectReceiverOptions));
let i = row.userIds.indexOf('PROCESSOR');
let i2 = row.userIds.indexOf('CREATOR');
switch (row.event) {
case "CREATE":
testPlanReceivers.unshift({id: 'PROCESSOR', name: '处理人'});
if (row.isSet) {
if (i < 0) {
row.userIds.unshift('PROCESSOR');
}
}
if (i2 > -1) {
row.userIds.splice(i2, 1);
}
break;
case "UPDATE":
case "STATUS_CHANGE":
testPlanReceivers.unshift({id: 'CREATOR', name: this.$t('commons.create_user')});
testPlanReceivers.unshift({id: 'PROCESSOR', name: '处理人'});
if (row.isSet) {
if (i2 < 0) {
row.userIds.unshift('CREATOR');
}
if (i < 0) {
row.userIds.unshift('PROCESSOR');
}
}
break;
case "DELETE":