fix(项目管理): 修复消息通知显示问题

This commit is contained in:
guoyuqi 2024-06-21 17:16:38 +08:00 committed by Craftsman
parent 85200437fd
commit 63000e9657
6 changed files with 56 additions and 46 deletions

View File

@ -7,48 +7,6 @@ update functional_case set last_execute_result = 'SUCCESS' where last_execute_re
update functional_case set last_execute_result = 'ERROR' where last_execute_result = 'FAILED';
update functional_case set last_execute_result = 'PENDING' where last_execute_result = 'SKIPPED';
DELIMITER //
CREATE PROCEDURE insert_into_message()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE a_id VARCHAR(50);
DECLARE cur CURSOR FOR
SELECT id
FROM project
WHERE project.id != '100001100001';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur;
read_loop: LOOP
FETCH cur INTO a_id;
IF done THEN
LEAVE read_loop;
END IF;
-- 插入到表B中
SET @robot_in_site_id = (select id as robotId from project_robot where project_id = a_id limit 1);
SET @test_plan_task_report_id = UUID_SHORT();
INSERT INTO message_task(id, event, receivers, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_report_id, 'DELETE', '["CREATE_USER"]', @robot_in_site_id, 'TEST_PLAN_REPORT_TASK', 'NONE', a_id, true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_report_task_delete');
INSERT INTO message_task_blob(id, template)
VALUES (@test_plan_task_report_id, 'message.test_plan_report_task_delete');
END LOOP;
CLOSE cur;
END//
DELIMITER ;
CALL insert_into_message();
DROP PROCEDURE IF EXISTS insert_into_message;
-- 初始化计划相关的权限 (删除V3.0.0_11_1测试计划模块相关的权限, 重新初始化, 模块树不单独拥有权限)
delete from user_role_permission where permission_id like 'PROJECT_TEST_PLAN_MODULE%' or permission_id like 'PROJECT_TEST_PLAN%';
-- 项目管理员(测试计划相关的权限)

View File

@ -18,5 +18,46 @@ UPDATE api_scenario_report SET exec_status='COMPLETED' WHERE status IN ('ERROR',
UPDATE api_scenario_report SET exec_status='STOPPED', status='-' WHERE status IN ('STOPPED');
UPDATE api_scenario_report SET exec_status='RUNNING', status='-' WHERE status IN ('RUNNING', 'PENDING');
UPDATE message_task SET receivers = '["CREATE_USER"]' WHERE receivers = '[""]';
DELIMITER //
CREATE PROCEDURE insert_into_message()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE a_id VARCHAR(50);
DECLARE cur CURSOR FOR
SELECT id
FROM project
WHERE project.id != '100001100001';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur;
read_loop: LOOP
FETCH cur INTO a_id;
IF done THEN
LEAVE read_loop;
END IF;
-- 插入到表B中
SET @robot_in_site_id = (select id as robotId from project_robot where project_id = a_id limit 1);
SET @test_plan_task_report_id = UUID_SHORT();
INSERT INTO message_task(id, event, receivers, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_report_id, 'DELETE', '["CREATE_USER"]', @robot_in_site_id, 'TEST_PLAN_REPORT_TASK', 'NONE', a_id, true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_report_task_delete');
INSERT INTO message_task_blob(id, template)
VALUES (@test_plan_task_report_id, 'message.test_plan_report_task_delete');
END LOOP;
CLOSE cur;
END//
DELIMITER ;
CALL insert_into_message();
DROP PROCEDURE IF EXISTS insert_into_message;
-- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -1093,7 +1093,7 @@
"eventName":"",
"receivers":[
{
"id": "",
"id": "CREATE_USER",
"name": ""
}
],
@ -1115,7 +1115,7 @@
"eventName":"",
"receivers":[
{
"id": "",
"id": "CREATE_USER",
"name": ""
}
],

View File

@ -1093,7 +1093,7 @@
"eventName":"",
"receivers":[
{
"id": "",
"id": "CREATE_USER",
"name": ""
}
],
@ -1115,7 +1115,7 @@
"eventName":"",
"receivers":[
{
"id": "",
"id": "CREATE_USER",
"name": ""
}
],

View File

@ -98,6 +98,9 @@ public class NotificationService {
if (k.contains("TEST_PLAN")) {
countMap.merge("TEST_PLAN", v.size(), Integer::sum);
}
if (k.contains("JENKINS")) {
countMap.merge("JENKINS", v.size(), Integer::sum);
}
});
countMap.forEach((k, v) -> {
OptionDTO optionDTO = new OptionDTO();

View File

@ -306,6 +306,8 @@
key = 'SCHEDULE';
} else if (key === 'TEST_PLAN_MANAGEMENT') {
key = 'TEST_PLAN';
} else if (key === 'JENKINS_TASK_MANAGEMENT') {
key = 'JENKINS';
} else {
key = '';
}
@ -376,6 +378,12 @@
count = module.name;
}
}
if (type === 'JENKINS_TASK_MANAGEMENT') {
const module = options.value.find((item) => item.id === 'JENKINS');
if (module) {
count = module.name;
}
}
const number = parseInt(count, 10);
if (number > 99) {
return '+99';