From 78c2ef0dd97a34200a4bb8abecb1ba7e24325f75 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Tue, 9 Dec 2025 11:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96SSH=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/replace_timestamps.py | 18 ++++++++++++++++++ .../db/changelog/changes/v1.0.0-data.sql | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 backend/replace_timestamps.py diff --git a/backend/replace_timestamps.py b/backend/replace_timestamps.py new file mode 100644 index 00000000..88d5ea01 --- /dev/null +++ b/backend/replace_timestamps.py @@ -0,0 +1,18 @@ +import re + +# 读取文件 +file_path = r'd:\work\java-space\deploy-ease-platform\backend\src\main\resources\db\changelog\changes\v1.0.0-data.sql' + +with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + +# 替换时间戳为 NOW() +# 匹配格式: 'YYYY-MM-DD HH:MM:SS' 或 'YYYY-MM-DD HH:MM:SS.ffffff' +pattern = r"'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?'" +new_content = re.sub(pattern, 'NOW()', content) + +# 写回文件 +with open(file_path, 'w', encoding='utf-8') as f: + f.write(new_content) + +print("替换完成!") diff --git a/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql b/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql index 619101a1..45010aab 100644 --- a/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql +++ b/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql @@ -759,7 +759,7 @@ INSERT INTO `deploy-ease-platform`.`sys_notification_channel` (`id`, `create_by` INSERT INTO `deploy-ease-platform`.`sys_notification_template` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `name`, `code`, `description`, `channel_type`, `title_template`, `content_template`, `enabled`, `template_config`) VALUES (8, 'admin', NOW(), 'dengqichen', NOW(), 36, b'0', 'JENKINS构建状态通知', 'jenkins_build_notification', '', 'WEWORK', '## <#if environmentName??>${environmentName}环境构建通知', '>项目:<#if applicationName??>${applicationName}(${applicationCode})\r\n<#if buildStatus??>\r\n<#switch buildStatus>\r\n<#case \"SUCCESS\">\r\n>状态:构建成功\r\n<#break>\r\n<#case \"BUILDING\">\r\n>状态:构建中\r\n<#break>\r\n<#case \"ABORTED\">\r\n>状态:构建被取消\r\n<#break>\r\n<#default>\r\n>状态:构建失败\r\n\r\n\r\n<#if buildStatus?? && buildStatus != \"BUILDING\">\r\n<#if buildDurationFormatted??>\r\n>耗时:${buildDurationFormatted}\r\n\r\n<#if buildEndTime??>\r\n>时间:${buildEndTime}\r\n\r\n<#else>\r\n<#if buildStartTime??>\r\n>时间:${buildStartTime}\r\n\r\n\r\n<#if commitMessage??>\r\n>内容:\r\n<#list commitMessage?split(\'\\n\') as line>\r\n>${line}\r\n\r\n', b'1', '{\"channelType\": \"WEWORK\", \"messageType\": \"MARKDOWN\"}'); INSERT INTO `deploy-ease-platform`.`sys_notification_template` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `name`, `code`, `description`, `channel_type`, `title_template`, `content_template`, `enabled`, `template_config`) VALUES (9, 'admin', NOW(), 'admin', NOW(), 10, b'0', '国产化构建通知', 'localization_build_notification', '国产化模版', 'WEWORK', '## <#if environmentName??>${environmentName}环境变更通知', '>项目:<#if applicationName??>${applicationName}(${applicationCode})\r\n<#-- 通过判断HTTP节点输出是否存在来区分阶段 -->\r\n<#if sid_d7bd35dc_37cc_4868_9c8a_9c854d5d6bbf?? && sid_d7bd35dc_37cc_4868_9c8a_9c854d5d6bbf.outputs??>\r\n<#-- ========== 构建结束阶段(HTTP节点已执行)========== -->\r\n<#assign httpOutput = sid_d7bd35dc_37cc_4868_9c8a_9c854d5d6bbf.outputs>\r\n<#if httpOutput.isSuccess!false>\r\n<#if httpOutput.responseBody?? && httpOutput.responseBody.status?? && httpOutput.responseBody.status == \"success\">\r\n>状态:构建成功\r\n<#if httpOutput.responseBody.duration??>\r\n>耗时:${httpOutput.responseBody.duration}秒\r\n\r\n<#if httpOutput.responseBody.endTime??>\r\n>时间:${httpOutput.responseBody.endTime}\r\n\r\n<#else>\r\n>状态:构建失败\r\n<#if httpOutput.responseBody?? && httpOutput.responseBody.error??>\r\n>错误:${httpOutput.responseBody.error}\r\n\r\n\r\n<#else>\r\n>状态:构建失败\r\n<#if httpOutput.statusCode?? && httpOutput.statusCode gt 0>\r\n>HTTP状态码:${httpOutput.statusCode}\r\n<#else>\r\n>错误类型:网络连接异常\r\n\r\n<#if httpOutput.errorMessage??>\r\n>错误详情:${httpOutput.errorMessage}\r\n\r\n<#if httpOutput.responseTime??>\r\n>请求耗时:${httpOutput.responseTime}ms\r\n\r\n\r\n<#else>\r\n<#-- ========== 构建中阶段(HTTP节点未执行)========== -->\r\n>状态:构建中\r\n<#if deployDate??>\r\n<#attempt>\r\n<#assign deployDateTime = deployDate?datetime.iso>\r\n>时间:${deployDateTime?string(\"yyyy-MM-dd HH:mm:ss\")}\r\n<#recover>\r\n>时间:${deployDate}\r\n\r\n\r\n\r\n>内容:<#if deployRemark??>${deployRemark}<#else>无构建内容\r\n', b'1', '{\"channelType\": \"WEWORK\", \"messageType\": \"MARKDOWN\"}'); INSERT INTO `deploy-ease-platform`.`sys_notification_template` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `name`, `code`, `description`, `channel_type`, `title_template`, `content_template`, `enabled`, `template_config`) VALUES (10, 'admin', NOW(), 'admin', NOW(), 3, b'0', 'Git同步检测通知', 'git_sync_code_check_notification', '', 'WEWORK', '## 代码同步检查异常', '${sid_e5f930da_062e_4819_b976_8d8172c7f14a.outputs.checkDetail}', b'1', '{\"channelType\": \"WEWORK\", \"messageType\": \"MARKDOWN\"}'); -INSERT INTO `deploy-ease-platform`.`sys_notification_template` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `name`, `code`, `description`, `channel_type`, `title_template`, `content_template`, `enabled`, `template_config`) VALUES (11, 'admin', NOW(), 'dengqichen', NOW(), 3, b'0', '服务器阈值预警通知', 'server_threshold_warning_notification', '', 'WEWORK', '## 服务器${alertLevel}告警通知', '> 服务器名称:${serverName}\r\n> 服务器IP:${serverIp}\r\n\r\n> 告警规则:${ruleName}-${alertType}-${resourceInfo}\r\n\r\n> 当前值:${currentValue}%,阈值:${threshold}%\r\n> 告警时间:${alertTime}\r\n\r\n请及时处理告警信息!', b'1', '{\"channelType\": \"WEWORK\", \"messageType\": \"MARKDOWN\"}'); +INSERT INTO `deploy-ease-platform`.`sys_notification_template` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `name`, `code`, `description`, `channel_type`, `title_template`, `content_template`, `enabled`, `template_config`) VALUES (11, 'admin', NOW(), 'dengqichen', NOW(), 4, b'0', '服务器阈值预警通知', 'server_threshold_warning_notification', '', 'WEWORK', '## 服务器${alertLevel}${resourceInfo}告警通知', '> 服务器名称:${serverName}\r\n\r\n> 告警规则:${ruleName}-${alertType}\r\n\r\n> 当前值:${currentValue}%,阈值:${threshold}%\r\n> 告警时间:${alertTime}\r\n\r\n请及时处理告警信息!', b'1', '{\"channelType\": \"WEWORK\", \"messageType\": \"MARKDOWN\"}'); INSERT INTO `deploy-ease-platform`.`sys_notification_template` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `name`, `code`, `description`, `channel_type`, `title_template`, `content_template`, `enabled`, `template_config`) VALUES (12, 'admin', NOW(), 'dengqichen', NOW(), 2, b'0', '服务器离线预警', 'server_offline_warning_notification', '', 'WEWORK', '## 服务器离线通知', '> 服务器名称:${serverName}\r\n\r\n**离线详情**\r\n> 检测时间:${offlineTime}\r\n> 状态:服务器无法访问\r\n\r\n请立即处理服务器离线问题!', b'1', '{\"channelType\": \"WEWORK\", \"messageType\": \"MARKDOWN\"}'); INSERT INTO `deploy-ease-platform`.`schedule_job_category` (`id`, `create_by`, `create_time`, `update_by`, `update_time`, `version`, `deleted`, `code`, `name`, `description`, `icon`, `color`, `enabled`, `sort`) VALUES (1, 'system', NOW(), 'system', NOW(), 1, b'0', 'DATA_CLEAN', '数据清理', '定期清理系统历史数据和临时文件', 'DeleteOutlined', '#ff4d4f', b'1', 1);