增加部署日志
This commit is contained in:
parent
edd34ae5db
commit
e672dd7e27
@ -39,11 +39,8 @@ public class UserDeployableTeamEnvironmentDTO {
|
||||
@Schema(description = "审批人列表")
|
||||
private List<UserDeployableTeamEnvironmentApproverDTO> approvers;
|
||||
|
||||
@Schema(description = "是否启用部署通知")
|
||||
private Boolean notificationEnabled;
|
||||
|
||||
@Schema(description = "通知渠道ID")
|
||||
private Long notificationChannelId;
|
||||
@Schema(description = "通知配置")
|
||||
private UserTeamEnvironmentNotificationConfigDTO notificationConfig;
|
||||
|
||||
@Schema(description = "是否要求代码审查")
|
||||
private Boolean requireCodeReview;
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package com.qqchen.deploy.backend.deploy.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户团队环境通知配置DTO
|
||||
*
|
||||
* @author qqchen
|
||||
* @since 2025-11-11
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户团队环境通知配置信息")
|
||||
public class UserTeamEnvironmentNotificationConfigDTO {
|
||||
|
||||
/**
|
||||
* 通知渠道ID
|
||||
*/
|
||||
@Schema(description = "通知渠道ID")
|
||||
private Long notificationChannelId;
|
||||
|
||||
/**
|
||||
* 是否启用部署通知
|
||||
*/
|
||||
@Schema(description = "是否启用部署通知")
|
||||
private Boolean deployNotificationEnabled;
|
||||
|
||||
/**
|
||||
* 是否启用构建通知
|
||||
*/
|
||||
@Schema(description = "是否启用构建通知")
|
||||
private Boolean buildNotificationEnabled;
|
||||
|
||||
/**
|
||||
* 构建失败时是否发送日志文件到企业微信
|
||||
*/
|
||||
@Schema(description = "构建失败时是否发送日志文件到企业微信")
|
||||
private Boolean buildFailureFileEnabled;
|
||||
|
||||
// ===== 扩展字段(非数据库字段) =====
|
||||
|
||||
/**
|
||||
* 通知渠道名称(扩展字段,非数据库字段)
|
||||
*/
|
||||
@Schema(description = "通知渠道名称(扩展字段,非数据库字段)")
|
||||
private String notificationChannelName;
|
||||
}
|
||||
@ -3,6 +3,8 @@ package com.qqchen.deploy.backend.deploy.service.impl;
|
||||
import com.qqchen.deploy.backend.deploy.dto.*;
|
||||
import com.qqchen.deploy.backend.deploy.entity.*;
|
||||
import com.qqchen.deploy.backend.deploy.repository.*;
|
||||
import com.qqchen.deploy.backend.notification.entity.NotificationChannel;
|
||||
import com.qqchen.deploy.backend.notification.repository.INotificationChannelRepository;
|
||||
import com.qqchen.deploy.backend.deploy.service.IDeployService;
|
||||
import com.qqchen.deploy.backend.framework.security.SecurityUtils;
|
||||
import com.qqchen.deploy.backend.framework.enums.ResponseCode;
|
||||
@ -105,6 +107,12 @@ public class DeployServiceImpl implements IDeployService {
|
||||
@Resource
|
||||
private IWorkflowNodeLogService workflowNodeLogService;
|
||||
|
||||
@Resource
|
||||
private ITeamEnvironmentNotificationConfigRepository teamEnvironmentNotificationConfigRepository;
|
||||
|
||||
@Resource
|
||||
private INotificationChannelRepository notificationChannelRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserTeamDeployableDTO> getDeployableEnvironments() {
|
||||
@ -229,7 +237,32 @@ public class DeployServiceImpl implements IDeployService {
|
||||
? workflowDefinitionRepository.findAllById(workflowIds).stream().collect(toMap(WorkflowDefinition::getId, w -> w))
|
||||
: Collections.emptyMap();
|
||||
|
||||
// 14. 批量查询审批人信息
|
||||
// 14. 批量查询通知配置
|
||||
Map<String, TeamEnvironmentNotificationConfig> notificationConfigMap = new HashMap<>();
|
||||
if (!teamIds.isEmpty() && !allEnvIds.isEmpty()) {
|
||||
List<TeamEnvironmentNotificationConfig> notificationConfigs =
|
||||
teamEnvironmentNotificationConfigRepository.findByTeamIdInAndEnvironmentIdIn(new HashSet<>(teamIds), allEnvIds);
|
||||
|
||||
notificationConfigs.forEach(nc -> {
|
||||
String key = nc.getTeamId() + "_" + nc.getEnvironmentId();
|
||||
notificationConfigMap.put(key, nc);
|
||||
});
|
||||
}
|
||||
|
||||
// 15. 批量查询通知渠道信息
|
||||
Set<Long> channelIds = notificationConfigMap.values().stream()
|
||||
.map(TeamEnvironmentNotificationConfig::getNotificationChannelId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Map<Long, NotificationChannel> channelMap = new HashMap<>();
|
||||
if (!channelIds.isEmpty()) {
|
||||
notificationChannelRepository.findAllById(channelIds).forEach(channel ->
|
||||
channelMap.put(channel.getId(), channel)
|
||||
);
|
||||
}
|
||||
|
||||
// 16. 批量查询审批人信息
|
||||
Set<Long> approverUserIds = teamEnvConfigs.stream()
|
||||
.filter(c -> c.getApproverUserIds() != null)
|
||||
.flatMap(c -> c.getApproverUserIds().stream())
|
||||
@ -243,13 +276,14 @@ public class DeployServiceImpl implements IDeployService {
|
||||
Map<Long, DeployRecord> latestRecordMap = queryLatestRecords(teamApplicationIds);
|
||||
Map<Long, List<DeployRecordSummaryDTO>> recentRecordsMap = queryRecentRecords(teamApplicationIds);
|
||||
|
||||
// 16. 为每个团队组装完整数据
|
||||
// 17. 为每个团队组装完整数据
|
||||
List<UserTeamDeployableDTO> result = new ArrayList<>();
|
||||
for (Long teamId : teamIds) {
|
||||
UserTeamDeployableDTO teamDTO = buildUserTeamDeployableDTO(
|
||||
currentUserId, teamId, teamMap, ownerMap, membersByTeam, memberUserMap,
|
||||
teamAppsMap, envMap, appMap, systemMap, workflowMap,
|
||||
teamEnvConfigMap, approverMap,
|
||||
notificationConfigMap, channelMap,
|
||||
statisticsMap, latestRecordMap, recentRecordsMap
|
||||
);
|
||||
if (teamDTO != null) {
|
||||
@ -278,6 +312,8 @@ public class DeployServiceImpl implements IDeployService {
|
||||
Map<Long, WorkflowDefinition> workflowMap,
|
||||
Map<String, TeamEnvironmentConfig> teamEnvConfigMap,
|
||||
Map<Long, User> approverMap,
|
||||
Map<String, TeamEnvironmentNotificationConfig> notificationConfigMap,
|
||||
Map<Long, NotificationChannel> channelMap,
|
||||
Map<Long, DeployStatisticsDTO> statisticsMap,
|
||||
Map<Long, DeployRecord> latestRecordMap,
|
||||
Map<Long, List<DeployRecordSummaryDTO>> recentRecordsMap
|
||||
@ -344,6 +380,7 @@ public class DeployServiceImpl implements IDeployService {
|
||||
teamId, env, envApps,
|
||||
appMap, systemMap, workflowMap,
|
||||
teamEnvConfigMap, approverMap,
|
||||
notificationConfigMap, channelMap,
|
||||
statisticsMap, latestRecordMap, recentRecordsMap
|
||||
);
|
||||
environments.add(envDTO);
|
||||
@ -370,6 +407,8 @@ public class DeployServiceImpl implements IDeployService {
|
||||
Map<Long, WorkflowDefinition> workflowMap,
|
||||
Map<String, TeamEnvironmentConfig> teamEnvConfigMap,
|
||||
Map<Long, User> approverMap,
|
||||
Map<String, TeamEnvironmentNotificationConfig> notificationConfigMap,
|
||||
Map<Long, NotificationChannel> channelMap,
|
||||
Map<Long, DeployStatisticsDTO> statisticsMap,
|
||||
Map<Long, DeployRecord> latestRecordMap,
|
||||
Map<Long, List<DeployRecordSummaryDTO>> recentRecordsMap
|
||||
@ -387,11 +426,9 @@ public class DeployServiceImpl implements IDeployService {
|
||||
TeamEnvironmentConfig config = teamEnvConfigMap.get(configKey);
|
||||
if (config != null) {
|
||||
boolean requiresApproval = config.getApprovalRequired() != null ? config.getApprovalRequired() : false;
|
||||
boolean notificationEnabled = config.getNotificationEnabled() != null ? config.getNotificationEnabled() : true;
|
||||
|
||||
dto.setRequiresApproval(requiresApproval);
|
||||
dto.setRequireCodeReview(config.getRequireCodeReview() != null ? config.getRequireCodeReview() : false);
|
||||
dto.setNotificationEnabled(notificationEnabled);
|
||||
|
||||
// 兜底逻辑:只有需要审批时才返回审批人列表
|
||||
if (requiresApproval && config.getApproverUserIds() != null && !config.getApproverUserIds().isEmpty()) {
|
||||
@ -414,17 +451,30 @@ public class DeployServiceImpl implements IDeployService {
|
||||
dto.setApprovers(Collections.emptyList());
|
||||
}
|
||||
|
||||
// 兜底逻辑:只有启用通知时才返回通知渠道ID
|
||||
if (notificationEnabled) {
|
||||
dto.setNotificationChannelId(config.getNotificationChannelId());
|
||||
} else {
|
||||
dto.setNotificationChannelId(null);
|
||||
// 构建通知配置
|
||||
UserTeamEnvironmentNotificationConfigDTO notificationConfigDTO = null;
|
||||
TeamEnvironmentNotificationConfig notificationConfig = notificationConfigMap.get(configKey);
|
||||
if (notificationConfig != null) {
|
||||
notificationConfigDTO = new UserTeamEnvironmentNotificationConfigDTO();
|
||||
notificationConfigDTO.setNotificationChannelId(notificationConfig.getNotificationChannelId());
|
||||
notificationConfigDTO.setDeployNotificationEnabled(notificationConfig.getDeployNotificationEnabled());
|
||||
notificationConfigDTO.setBuildNotificationEnabled(notificationConfig.getBuildNotificationEnabled());
|
||||
notificationConfigDTO.setBuildFailureFileEnabled(notificationConfig.getBuildFailureFileEnabled());
|
||||
|
||||
// 设置通知渠道名称
|
||||
if (notificationConfig.getNotificationChannelId() != null) {
|
||||
NotificationChannel channel = channelMap.get(notificationConfig.getNotificationChannelId());
|
||||
if (channel != null) {
|
||||
notificationConfigDTO.setNotificationChannelName(channel.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
dto.setNotificationConfig(notificationConfigDTO);
|
||||
} else {
|
||||
dto.setRequiresApproval(false);
|
||||
dto.setRequireCodeReview(false);
|
||||
dto.setNotificationEnabled(true);
|
||||
dto.setApprovers(Collections.emptyList());
|
||||
dto.setNotificationConfig(null);
|
||||
}
|
||||
|
||||
// 构建应用列表
|
||||
|
||||
Loading…
Reference in New Issue
Block a user