增加构建通知
This commit is contained in:
parent
41c7a88542
commit
a0ac1c5205
@ -65,4 +65,19 @@ public class TeamEnvironmentNotificationConfigDTO extends BaseDTO {
|
|||||||
* 通知渠道名称(扩展字段,非数据库字段)
|
* 通知渠道名称(扩展字段,非数据库字段)
|
||||||
*/
|
*/
|
||||||
private String notificationChannelName;
|
private String notificationChannelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署通知模板名称(扩展字段,非数据库字段)
|
||||||
|
*/
|
||||||
|
private String deployNotificationTemplateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建通知模板名称(扩展字段,非数据库字段)
|
||||||
|
*/
|
||||||
|
private String buildNotificationTemplateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建失败通知模板名称(扩展字段,非数据库字段)
|
||||||
|
*/
|
||||||
|
private String buildFailureNotificationTemplateName;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,4 +62,22 @@ public class UserTeamEnvironmentNotificationConfigDTO {
|
|||||||
*/
|
*/
|
||||||
@Schema(description = "通知渠道名称(扩展字段,非数据库字段)")
|
@Schema(description = "通知渠道名称(扩展字段,非数据库字段)")
|
||||||
private String notificationChannelName;
|
private String notificationChannelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署通知模板名称(扩展字段,非数据库字段)
|
||||||
|
*/
|
||||||
|
@Schema(description = "部署通知模板名称(扩展字段,非数据库字段)")
|
||||||
|
private String deployNotificationTemplateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建通知模板名称(扩展字段,非数据库字段)
|
||||||
|
*/
|
||||||
|
@Schema(description = "构建通知模板名称(扩展字段,非数据库字段)")
|
||||||
|
private String buildNotificationTemplateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建失败通知模板名称(扩展字段,非数据库字段)
|
||||||
|
*/
|
||||||
|
@Schema(description = "构建失败通知模板名称(扩展字段,非数据库字段)")
|
||||||
|
private String buildFailureNotificationTemplateName;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,9 @@ import com.qqchen.deploy.backend.framework.enums.ResponseCode;
|
|||||||
import com.qqchen.deploy.backend.framework.exception.BusinessException;
|
import com.qqchen.deploy.backend.framework.exception.BusinessException;
|
||||||
import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl;
|
import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl;
|
||||||
import com.qqchen.deploy.backend.notification.entity.NotificationChannel;
|
import com.qqchen.deploy.backend.notification.entity.NotificationChannel;
|
||||||
|
import com.qqchen.deploy.backend.notification.entity.NotificationTemplate;
|
||||||
import com.qqchen.deploy.backend.notification.repository.INotificationChannelRepository;
|
import com.qqchen.deploy.backend.notification.repository.INotificationChannelRepository;
|
||||||
|
import com.qqchen.deploy.backend.notification.repository.INotificationTemplateRepository;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -48,6 +50,9 @@ public class TeamEnvironmentConfigServiceImpl
|
|||||||
@Resource
|
@Resource
|
||||||
private INotificationChannelRepository notificationChannelRepository;
|
private INotificationChannelRepository notificationChannelRepository;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private INotificationTemplateRepository notificationTemplateRepository;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ITeamApplicationRepository teamApplicationRepository;
|
private ITeamApplicationRepository teamApplicationRepository;
|
||||||
|
|
||||||
@ -272,7 +277,28 @@ public class TeamEnvironmentConfigServiceImpl
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 填充扩展字段
|
// 5. 批量查询通知模板信息
|
||||||
|
Set<Long> templateIds = new HashSet<>();
|
||||||
|
notificationConfigMap.values().forEach(nc -> {
|
||||||
|
if (nc.getDeployNotificationTemplateId() != null) {
|
||||||
|
templateIds.add(nc.getDeployNotificationTemplateId());
|
||||||
|
}
|
||||||
|
if (nc.getBuildNotificationTemplateId() != null) {
|
||||||
|
templateIds.add(nc.getBuildNotificationTemplateId());
|
||||||
|
}
|
||||||
|
if (nc.getBuildFailureNotificationTemplateId() != null) {
|
||||||
|
templateIds.add(nc.getBuildFailureNotificationTemplateId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<Long, NotificationTemplate> templateMap = new HashMap<>();
|
||||||
|
if (!templateIds.isEmpty()) {
|
||||||
|
notificationTemplateRepository.findAllById(templateIds).forEach(template ->
|
||||||
|
templateMap.put(template.getId(), template)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 填充扩展字段
|
||||||
configs.forEach(config -> {
|
configs.forEach(config -> {
|
||||||
// 填充环境名称
|
// 填充环境名称
|
||||||
if (config.getEnvironmentId() != null) {
|
if (config.getEnvironmentId() != null) {
|
||||||
@ -299,6 +325,30 @@ public class TeamEnvironmentConfigServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 填充部署通知模板名称
|
||||||
|
if (notificationConfig.getDeployNotificationTemplateId() != null) {
|
||||||
|
NotificationTemplate template = templateMap.get(notificationConfig.getDeployNotificationTemplateId());
|
||||||
|
if (template != null) {
|
||||||
|
notificationConfigDTO.setDeployNotificationTemplateName(template.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充构建通知模板名称
|
||||||
|
if (notificationConfig.getBuildNotificationTemplateId() != null) {
|
||||||
|
NotificationTemplate template = templateMap.get(notificationConfig.getBuildNotificationTemplateId());
|
||||||
|
if (template != null) {
|
||||||
|
notificationConfigDTO.setBuildNotificationTemplateName(template.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充构建失败通知模板名称
|
||||||
|
if (notificationConfig.getBuildFailureNotificationTemplateId() != null) {
|
||||||
|
NotificationTemplate template = templateMap.get(notificationConfig.getBuildFailureNotificationTemplateId());
|
||||||
|
if (template != null) {
|
||||||
|
notificationConfigDTO.setBuildFailureNotificationTemplateName(template.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config.setNotificationConfig(notificationConfigDTO);
|
config.setNotificationConfig(notificationConfigDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user