Files
DMS/DMS.Application/Profiles/MappingProfile.cs
David P.G a3af5dd0cc refactor: 移除 VariableMqttAliasDto 并替换为 VariableMqttAlias
本次重构移除了 VariableMqttAliasDto,并将其所有用法替换为 VariableMqttAlias 模型。

  主要变更:
  - 在 DTO、服务和接口中将 VariableMqttAliasDto 替换为 VariableMqttAlias。
  - 删除了 VariableMqttAliasDto 的 AutoMapper 映射。
  - 删除了 VariableMqttAliasDto.cs 文件。
2025-10-06 17:25:05 +08:00

64 lines
2.1 KiB
C#

using AutoMapper;
using DMS.Core.Models;
using DMS.Application.DTOs;
using DMS.Core.Models.Triggers;
namespace DMS.Application.Profiles;
/// <summary>
/// 配置AutoMapper的映射规则。
/// </summary>
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<Device, DeviceDto>()
.ReverseMap();
// VariableTable 映射
CreateMap<VariableTable, VariableTableDto>().ReverseMap();
// Variable 映射
CreateMap<Variable, VariableDto>()
.ReverseMap();
CreateMap<VariableDto, Variable>()
.ReverseMap();
CreateMap<VariableDto, VariableDto>()
.ReverseMap();
// MqttServer 映射
CreateMap<MqttServer, MqttServerDto>().ReverseMap();
CreateMap<MqttServerDto, MqttServerDto>().ReverseMap();
// VariableHistory 映射
CreateMap<VariableHistory, VariableHistoryDto>()
.ForMember(dest => dest.VariableName, opt => opt.MapFrom(src => src.Variable.Name))
.ReverseMap();
// MenuBean 映射
CreateMap<MenuBean, MenuBeanDto>().ReverseMap();
// User 映射
CreateMap<User, UserDto>().ReverseMap();
CreateMap<Nlog, NlogDto>().ReverseMap();
// 邮件相关映射
CreateMap<EmailAccount, EmailAccountDto>().ReverseMap();
CreateMap<EmailAccount, CreateEmailAccountRequest>().ReverseMap();
CreateMap<EmailMessage, EmailMessageDto>().ReverseMap();
CreateMap<EmailMessage, SendEmailRequest>()
.ForMember(dest => dest.EmailAccountId, opt => opt.MapFrom(src => src.EmailAccountId))
.ReverseMap();
CreateMap<EmailTemplate, EmailTemplateDto>().ReverseMap();
CreateMap<EmailLog, EmailLogDto>().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));
}
}