继续修改触发器(未完成,修改一个触发器可以添加多个变量)

This commit is contained in:
2025-09-22 22:58:51 +08:00
parent 0f869cf410
commit 042bc15288
14 changed files with 434 additions and 121 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using DMS.Core.Models.Triggers;
// 引入枚举
@@ -15,9 +16,9 @@ namespace DMS.Application.DTOs
public int Id { get; set; }
/// <summary>
/// 关联的变量 ID
/// 关联的变量 ID 列表
/// </summary>
public int VariableId { get; set; }
public List<int> VariableIds { get; set; } = new List<int>();
/// <summary>
/// 触发器是否处于激活状态

View File

@@ -57,6 +57,9 @@ public class MappingProfile : Profile
CreateMap<EmailTemplate, EmailTemplateDto>().ReverseMap();
CreateMap<EmailLog, EmailLogDto>().ReverseMap();
CreateMap<TriggerDefinition, TriggerDefinitionDto>().ReverseMap();
CreateMap<TriggerDefinition, TriggerDefinitionDto>()
.ForMember(dest => dest.VariableIds, opt => opt.MapFrom(src => src.VariableIds))
.ReverseMap()
.ForMember(dest => dest.VariableIds, opt => opt.MapFrom(src => src.VariableIds));
}
}

View File

@@ -109,6 +109,10 @@ namespace DMS.Application.Services.Triggers.Impl
/// </summary>
private void ValidateTriggerDto(TriggerDefinitionDto dto)
{
// 检查是否至少关联了一个变量
if (dto.VariableIds == null || !dto.VariableIds.Any())
throw new ArgumentException("触发器必须至少关联一个变量。");
// 添加必要的验证逻辑
switch (dto.Condition)
{