- Replaced instances of the previous messaging system with LiteCqrs across various application components, enhancing the CQRS implementation. - Updated dependency injection to register LiteCqrs services and behaviors, streamlining command and query handling. - Adjusted multiple command and query handlers to align with the new messaging framework, ensuring consistent functionality and improved maintainability. - Added LiteCqrs package reference in the project file for better dependency management.
30 lines
778 B
C#
30 lines
778 B
C#
using PnvPanel.Api.Common;
|
|
using LiteCqrs;
|
|
using PnvPanel.Application.Common.Models;
|
|
using PnvPanel.Application.News;
|
|
|
|
namespace PnvPanel.Api.Endpoints;
|
|
|
|
public static class NewsEndpoints
|
|
{
|
|
public static IEndpointRouteBuilder MapNewsEndpoints(this IEndpointRouteBuilder app)
|
|
{
|
|
app.MapGet("/api/news", ListNews)
|
|
.WithTags("News")
|
|
.RequireAuthorization()
|
|
.Produces<PagedList<NewsPostDto>>();
|
|
return app;
|
|
}
|
|
|
|
private static async Task<IResult> ListNews(
|
|
int page,
|
|
int pageSize,
|
|
ISender sender,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
var result = await sender.Send(new ListNewsQuery(page, pageSize), cancellationToken);
|
|
return result.ToHttpResult();
|
|
}
|
|
}
|