![]() |
VOOZH | about |
dotnet add package Eaf.Middleware.Application --version 9.1.0
NuGet\Install-Package Eaf.Middleware.Application -Version 9.1.0
<PackageReference Include="Eaf.Middleware.Application" Version="9.1.0" />
<PackageVersion Include="Eaf.Middleware.Application" Version="9.1.0" />Directory.Packages.props
<PackageReference Include="Eaf.Middleware.Application" />Project file
paket add Eaf.Middleware.Application --version 9.1.0
#r "nuget: Eaf.Middleware.Application, 9.1.0"
#:package Eaf.Middleware.Application@9.1.0
#addin nuget:?package=Eaf.Middleware.Application&version=9.1.0Install as a Cake Addin
#tool nuget:?package=Eaf.Middleware.Application&version=9.1.0Install as a Cake Tool
O Eaf.Middleware.Application é a camada de aplicação do Enterprise Application Foundation (EAF). Este módulo fornece DTOs (Data Transfer Objects), serviços de aplicação, validações e lógica de negócio intermediária, servindo como ponte entre a camada de domínio (Core) e a camada de apresentação (Web).
Este módulo segue os padrões de Application Layer do Domain-Driven Design (DDD) e implementa o padrão CQRS (Command Query Responsibility Segregation) através de serviços de aplicação.
MiddlewareAppServiceBase)dotnet add package Eaf.Middleware.Application --version 10.4.0
Adicione a referência ao seu arquivo .csproj:
<ProjectReference Include="..\Eaf.Middleware.Application\Eaf.Middleware.Application.csproj" />
No seu módulo principal, herde de MiddlewareApplicationModule:
[DependsOn(
typeof(MiddlewareCoreModule),
typeof(MiddlewareApplicationModule),
typeof(AbpAutoMapperModule)
)]
public class MyWebModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
public class TaskAppService : MiddlewareAppServiceBase, ITaskAppService
{
private readonly IRepository<Task> _taskRepository;
public TaskAppService(IRepository<Task> taskRepository)
{
_taskRepository = taskRepository;
}
[AbpAuthorize(MyPermissions.UpdateTasks)]
public async Task UpdateTask(UpdateTaskInput input)
{
Logger.Info($"Updating task {input.TaskId}");
var task = await _taskRepository.FirstOrDefaultAsync(input.TaskId);
if (task == null)
{
throw new UserFriendlyException(L("TaskNotFound"));
}
ObjectMapper.Map(input, task);
}
public async Task<TaskDto> GetTask(GetTaskInput input)
{
var task = await _taskRepository.FirstOrDefaultAsync(input.TaskId);
return ObjectMapper.Map<TaskDto>(task);
}
}
public class UpdateTaskInput
{
[Required]
public int TaskId { get; set; }
[Required]
[StringLength(Task.MaxTitleLength)]
public string Title { get; set; }
[StringLength(Task.MaxDescriptionLength)]
public string Description { get; set; }
}
public class TaskDto
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime CreationTime { get; set; }
}
No arquivo MiddlewareCustomDtoMapper.cs:
public class MiddlewareCustomDtoMapper : Profile
{
public MiddlewareCustomDtoMapper()
{
CreateMap<Task, TaskDto>();
CreateMap<CreateTaskInput, Task>();
CreateMap<UpdateTaskInput, Task>();
}
}
public class NotificationAppService : MiddlewareAppServiceBase, INotificationAppService
{
private readonly INotificationPublisher _notificationPublisher;
public NotificationAppService(INotificationPublisher notificationPublisher)
{
_notificationPublisher = notificationPublisher;
}
public async Task SendNotificationAsync(SendNotificationInput input)
{
await _notificationPublisher.PublishAsync(
"MyNotification",
new NotificationData(input.Message),
userIds: new[] { input.TargetUserId }
);
}
}
public class DataExportAppService : MiddlewareAppServiceBase, IDataExportAppService
{
public async Task<FileDto> ExportTasksToExcel(GetTasksInput input)
{
var tasks = await _taskRepository.GetAllListAsync();
var excelFile = new ExcelFileCreator();
var file = excelFile.CreateExcelFile(tasks);
return file;
}
}
Eaf.Middleware.Application/
├── Auditing/ # Serviços de auditoria
├── Authorization/ # Serviços de autorização
├── Chat/ # Serviços de chat
├── Common/ # Classes comuns
├── Configuration/ # Serviços de configuração
├── DataExporting/ # Exportação de dados
├── Dto/ # DTOs base
├── Friendships/ # Serviços de amizades
├── Localization/ # Arquivos de localização
├── Logging/ # Serviços de logging
├── Maintenance/ # Serviços de manutenção
├── MultiTenancy/ # Serviços multi-tenant
├── Net/ # Serviços de rede
├── Notifications/ # Sistema de notificações
├── RealTime/ # Comunicação em tempo real
├── Security/ # Serviços de segurança
├── Sessions/ # Gerenciamento de sessões
├── UiCustomization/ # Customização de UI
└── WebHooks/ # Integração com webhooks
public override void Initialize()
{
var thisAssembly = Assembly.GetExecutingAssembly();
Configuration.Modules.AbpAutoMapper().Configurators.Add(
cfg => cfg.AddMaps(thisAssembly)
);
}
public override void PreInitialize()
{
Configuration.ReplaceService<INotificationPublisher, MyNotificationPublisher>(
DependencyLifeStyle.Transient
);
}
Atualmente, este módulo não possui testes unitários. Para criar testes, siga o padrão dos outros módulos do EAF:
# Criar projeto de teste
dotnet new xunit -n Eaf.Middleware.Application.Tests
# Adicionar referências
dotnet add Eaf.Middleware.Application.Tests reference ../src/Eaf.Middleware.Application
dotnet add Eaf.Middleware.Application.Tests package Abp.TestBase
dotnet add Eaf.Middleware.Application.Tests package Shouldly
dotnet add Eaf.Middleware.Application.Tests package NSubstitute
Exemplo de teste:
public class TaskAppService_Tests : AppTestBase
{
private readonly ITaskAppService _taskAppService;
public TaskAppService_Tests()
{
_taskAppService = Resolve<ITaskAppService>();
}
[Fact]
public async Task Should_Update_Task()
{
// Arrange
var task = await CreateTaskAsync("Test Task");
var input = new UpdateTaskInput
{
TaskId = task.Id,
Title = "Updated Task"
};
// Act
await _taskAppService.UpdateTask(input);
// Assert
var updatedTask = await GetTaskAsync(task.Id);
updatedTask.Title.ShouldBe("Updated Task");
}
}
Este projeto faz parte do Enterprise Application Foundation (EAF) e está licenciado sob os mesmos termos do projeto principal.
Para issues e perguntas, consulte o repositório principal do EAF: https://github.com/afonsoft/EAF
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Eaf.Middleware.Application:
| Package | Downloads |
|---|---|
|
Eaf.Middleware.Web.Core
Enterprise Application Foundation - Module Middleware - WebCore Classes |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 40 | 6/17/2026 |