增加构建通知

This commit is contained in:
dengqichen 2025-11-27 15:40:17 +08:00
parent 71e20202da
commit 1af85b2940
8 changed files with 42 additions and 88 deletions

View File

@ -28,12 +28,10 @@ public interface TeamEnvironmentNotificationConfigConverter
*/ */
@Mapping(target = "notificationChannelName", @Mapping(target = "notificationChannelName",
expression = "java(getChannelName(config.getNotificationChannelId(), channelMap))") expression = "java(getChannelName(config.getNotificationChannelId(), channelMap))")
@Mapping(target = "deployNotificationTemplateName", @Mapping(target = "preApprovalNotificationTemplateName",
expression = "java(getTemplateName(config.getDeployNotificationTemplateId(), templateMap))") expression = "java(getTemplateName(config.getPreApprovalNotificationTemplateId(), templateMap))")
@Mapping(target = "buildNotificationTemplateName", @Mapping(target = "buildNotificationTemplateName",
expression = "java(getTemplateName(config.getBuildNotificationTemplateId(), templateMap))") expression = "java(getTemplateName(config.getBuildNotificationTemplateId(), templateMap))")
@Mapping(target = "buildFailureNotificationTemplateName",
expression = "java(getTemplateName(config.getBuildFailureNotificationTemplateId(), templateMap))")
UserTeamEnvironmentNotificationConfigDTO toUserDTO( UserTeamEnvironmentNotificationConfigDTO toUserDTO(
TeamEnvironmentNotificationConfig config, TeamEnvironmentNotificationConfig config,
@Context Map<Long, NotificationChannel> channelMap, @Context Map<Long, NotificationChannel> channelMap,

View File

@ -116,11 +116,11 @@ public class DeployExecuteRequest {
@Schema(description = "通知渠道ID") @Schema(description = "通知渠道ID")
private Long notificationChannelId; private Long notificationChannelId;
@Schema(description = "是否启用部署通知") @Schema(description = "是否启用审批前提醒")
private Boolean deployNotificationEnabled; private Boolean preApprovalNotificationEnabled;
@Schema(description = "部署通知模板ID") @Schema(description = "审批前提醒模板ID")
private Long deployNotificationTemplateId; private Long preApprovalNotificationTemplateId;
@Schema(description = "是否启用构建通知") @Schema(description = "是否启用构建通知")
private Boolean buildNotificationEnabled; private Boolean buildNotificationEnabled;
@ -128,11 +128,8 @@ public class DeployExecuteRequest {
@Schema(description = "构建通知模板ID") @Schema(description = "构建通知模板ID")
private Long buildNotificationTemplateId; private Long buildNotificationTemplateId;
@Schema(description = "构建失败时是否发送日志文件到企业微信") @Schema(description = "构建失败时是否发送日志文件")
private Boolean buildFailureFileEnabled; private Boolean buildFailureFileEnabled;
@Schema(description = "构建失败通知模板ID")
private Long buildFailureNotificationTemplateId;
} }
} }

View File

@ -30,14 +30,14 @@ public class TeamEnvironmentNotificationConfigDTO extends BaseDTO {
private Long notificationChannelId; private Long notificationChannelId;
/** /**
* 是否启用部署通知 * 是否启用审批前提醒
*/ */
private Boolean deployNotificationEnabled; private Boolean preApprovalNotificationEnabled;
/** /**
* 部署通知模板ID * 审批前提醒模板ID
*/ */
private Long deployNotificationTemplateId; private Long preApprovalNotificationTemplateId;
/** /**
* 是否启用构建通知 * 是否启用构建通知
@ -50,15 +50,10 @@ public class TeamEnvironmentNotificationConfigDTO extends BaseDTO {
private Long buildNotificationTemplateId; private Long buildNotificationTemplateId;
/** /**
* 构建失败时是否发送日志文件到企业微信 * 构建失败时是否发送日志文件
*/ */
private Boolean buildFailureFileEnabled; private Boolean buildFailureFileEnabled;
/**
* 构建失败通知模板ID
*/
private Long buildFailureNotificationTemplateId;
// ===== 扩展字段非数据库字段 ===== // ===== 扩展字段非数据库字段 =====
/** /**
@ -67,17 +62,12 @@ public class TeamEnvironmentNotificationConfigDTO extends BaseDTO {
private String notificationChannelName; private String notificationChannelName;
/** /**
* 部署通知模板名称扩展字段非数据库字段 * 审批前提醒模板名称扩展字段非数据库字段
*/ */
private String deployNotificationTemplateName; private String preApprovalNotificationTemplateName;
/** /**
* 构建通知模板名称扩展字段非数据库字段 * 构建通知模板名称扩展字段非数据库字段
*/ */
private String buildNotificationTemplateName; private String buildNotificationTemplateName;
/**
* 构建失败通知模板名称扩展字段非数据库字段
*/
private String buildFailureNotificationTemplateName;
} }

View File

@ -20,16 +20,16 @@ public class UserTeamEnvironmentNotificationConfigDTO {
private Long notificationChannelId; private Long notificationChannelId;
/** /**
* 是否启用部署通知 * 是否启用审批前提醒
*/ */
@Schema(description = "是否启用部署通知") @Schema(description = "是否启用审批前提醒")
private Boolean deployNotificationEnabled; private Boolean preApprovalNotificationEnabled;
/** /**
* 部署通知模板ID * 审批前提醒模板ID
*/ */
@Schema(description = "部署通知模板ID") @Schema(description = "审批前提醒模板ID")
private Long deployNotificationTemplateId; private Long preApprovalNotificationTemplateId;
/** /**
* 是否启用构建通知 * 是否启用构建通知
@ -44,17 +44,11 @@ public class UserTeamEnvironmentNotificationConfigDTO {
private Long buildNotificationTemplateId; private Long buildNotificationTemplateId;
/** /**
* 构建失败时是否发送日志文件到企业微信 * 构建失败时是否发送日志文件
*/ */
@Schema(description = "构建失败时是否发送日志文件到企业微信") @Schema(description = "构建失败时是否发送日志文件")
private Boolean buildFailureFileEnabled; private Boolean buildFailureFileEnabled;
/**
* 构建失败通知模板ID
*/
@Schema(description = "构建失败通知模板ID")
private Long buildFailureNotificationTemplateId;
// ===== 扩展字段非数据库字段 ===== // ===== 扩展字段非数据库字段 =====
/** /**
@ -64,20 +58,14 @@ public class UserTeamEnvironmentNotificationConfigDTO {
private String notificationChannelName; private String notificationChannelName;
/** /**
* 部署通知模板名称扩展字段非数据库字段 * 审批前提醒模板名称扩展字段非数据库字段
*/ */
@Schema(description = "部署通知模板名称(扩展字段,非数据库字段)") @Schema(description = "审批前提醒模板名称(扩展字段,非数据库字段)")
private String deployNotificationTemplateName; private String preApprovalNotificationTemplateName;
/** /**
* 构建通知模板名称扩展字段非数据库字段 * 构建通知模板名称扩展字段非数据库字段
*/ */
@Schema(description = "构建通知模板名称(扩展字段,非数据库字段)") @Schema(description = "构建通知模板名称(扩展字段,非数据库字段)")
private String buildNotificationTemplateName; private String buildNotificationTemplateName;
/**
* 构建失败通知模板名称扩展字段非数据库字段
*/
@Schema(description = "构建失败通知模板名称(扩展字段,非数据库字段)")
private String buildFailureNotificationTemplateName;
} }

View File

@ -46,16 +46,16 @@ public class TeamEnvironmentNotificationConfig extends Entity<Long> {
private Long notificationChannelId; private Long notificationChannelId;
/** /**
* 是否启用部署通知 * 是否启用审批前提醒
*/ */
@Column(name = "deploy_notification_enabled", nullable = false, columnDefinition = "BIT DEFAULT 1") @Column(name = "pre_approval_notification_enabled", nullable = false)
private Boolean deployNotificationEnabled = true; private Boolean preApprovalNotificationEnabled = false;
/** /**
* 部署通知模板ID关联sys_notification_template * 审批前提醒模板ID关联sys_notification_template
*/ */
@Column(name = "deploy_notification_template_id") @Column(name = "pre_approval_notification_template_id")
private Long deployNotificationTemplateId; private Long preApprovalNotificationTemplateId;
/** /**
* 是否启用构建通知 * 是否启用构建通知
@ -74,10 +74,4 @@ public class TeamEnvironmentNotificationConfig extends Entity<Long> {
*/ */
@Column(name = "build_failure_file_enabled", nullable = false) @Column(name = "build_failure_file_enabled", nullable = false)
private Boolean buildFailureFileEnabled = false; private Boolean buildFailureFileEnabled = false;
/**
* 构建失败通知模板ID关联sys_notification_template
*/
@Column(name = "build_failure_notification_template_id")
private Long buildFailureNotificationTemplateId;
} }

View File

@ -275,9 +275,8 @@ public class DeployServiceImpl implements IDeployService {
// 16. 批量查询通知模板信息 // 16. 批量查询通知模板信息
Set<Long> templateIds = notificationConfigMap.values().stream() Set<Long> templateIds = notificationConfigMap.values().stream()
.flatMap(config -> Stream.of( .flatMap(config -> Stream.of(
config.getDeployNotificationTemplateId(), config.getPreApprovalNotificationTemplateId(),
config.getBuildNotificationTemplateId(), config.getBuildNotificationTemplateId()
config.getBuildFailureNotificationTemplateId()
)) ))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toSet()); .collect(Collectors.toSet());

View File

@ -280,15 +280,12 @@ public class TeamEnvironmentConfigServiceImpl
// 5. 批量查询通知模板信息 // 5. 批量查询通知模板信息
Set<Long> templateIds = new HashSet<>(); Set<Long> templateIds = new HashSet<>();
notificationConfigMap.values().forEach(nc -> { notificationConfigMap.values().forEach(nc -> {
if (nc.getDeployNotificationTemplateId() != null) { if (nc.getPreApprovalNotificationTemplateId() != null) {
templateIds.add(nc.getDeployNotificationTemplateId()); templateIds.add(nc.getPreApprovalNotificationTemplateId());
} }
if (nc.getBuildNotificationTemplateId() != null) { if (nc.getBuildNotificationTemplateId() != null) {
templateIds.add(nc.getBuildNotificationTemplateId()); templateIds.add(nc.getBuildNotificationTemplateId());
} }
if (nc.getBuildFailureNotificationTemplateId() != null) {
templateIds.add(nc.getBuildFailureNotificationTemplateId());
}
}); });
Map<Long, NotificationTemplate> templateMap = new HashMap<>(); Map<Long, NotificationTemplate> templateMap = new HashMap<>();
@ -325,11 +322,11 @@ public class TeamEnvironmentConfigServiceImpl
} }
} }
// 填充部署通知模板名称 // 填充审批前提醒模板名称
if (notificationConfig.getDeployNotificationTemplateId() != null) { if (notificationConfig.getPreApprovalNotificationTemplateId() != null) {
NotificationTemplate template = templateMap.get(notificationConfig.getDeployNotificationTemplateId()); NotificationTemplate template = templateMap.get(notificationConfig.getPreApprovalNotificationTemplateId());
if (template != null) { if (template != null) {
notificationConfigDTO.setDeployNotificationTemplateName(template.getName()); notificationConfigDTO.setPreApprovalNotificationTemplateName(template.getName());
} }
} }
@ -341,14 +338,6 @@ public class TeamEnvironmentConfigServiceImpl
} }
} }
// 填充构建失败通知模板名称
if (notificationConfig.getBuildFailureNotificationTemplateId() != null) {
NotificationTemplate template = templateMap.get(notificationConfig.getBuildFailureNotificationTemplateId());
if (template != null) {
notificationConfigDTO.setBuildFailureNotificationTemplateName(template.getName());
}
}
config.setNotificationConfig(notificationConfigDTO); config.setNotificationConfig(notificationConfigDTO);
} }
} }

View File

@ -873,12 +873,11 @@ CREATE TABLE deploy_team_environment_notification_config
environment_id BIGINT NOT NULL COMMENT '环境ID', environment_id BIGINT NOT NULL COMMENT '环境ID',
notification_channel_id BIGINT NULL COMMENT '通知渠道ID关联sys_notification_channel', notification_channel_id BIGINT NULL COMMENT '通知渠道ID关联sys_notification_channel',
deploy_notification_enabled BIT NOT NULL DEFAULT 1 COMMENT '是否启用部署通知', pre_approval_notification_enabled BIT NOT NULL DEFAULT 0 COMMENT '是否启用审批前提醒',
deploy_notification_template_id BIGINT NULL COMMENT '部署通知模板ID关联sys_notification_template', pre_approval_notification_template_id BIGINT NULL COMMENT '审批前提醒模板ID关联sys_notification_template',
build_notification_enabled BIT NOT NULL DEFAULT 0 COMMENT '是否启用构建通知', build_notification_enabled BIT NOT NULL DEFAULT 0 COMMENT '是否启用构建通知',
build_notification_template_id BIGINT NULL COMMENT '构建通知模板ID关联sys_notification_template', build_notification_template_id BIGINT NULL COMMENT '构建通知模板ID关联sys_notification_template',
build_failure_log_enabled BIT NOT NULL DEFAULT 0 COMMENT '构建失败时是否附加错误日志到通知0不附加1附加', build_failure_file_enabled BIT NOT NULL DEFAULT 0 COMMENT '构建失败时是否发送日志文件0不发送1发送',
build_failure_notification_template_id BIGINT NULL COMMENT '构建失败通知模板ID关联sys_notification_template',
UNIQUE INDEX uk_team_env (team_id, environment_id), UNIQUE INDEX uk_team_env (team_id, environment_id),
INDEX idx_team (team_id), INDEX idx_team (team_id),