Реализован модуль каталога, миграции, сваггер
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Nashel.Modules.Catalog.Application.Commands;
|
||||
using Nashel.Modules.Catalog.Application.Queries;
|
||||
|
||||
namespace Nashel.Modules.Catalog.Presentation.Endpoints;
|
||||
|
||||
/// <summary>
|
||||
/// API Каталога (Категории и Услуги).
|
||||
/// </summary>
|
||||
public static class CatalogEndpoints
|
||||
{
|
||||
public static void MapCatalogEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var catalogGroup = app.MapGroup("/api/catalog").WithTags("Catalog");
|
||||
|
||||
// --- Категории ---
|
||||
|
||||
catalogGroup.MapPost("/categories", async ([FromBody] CreateCategoryCommand command, ISender sender) =>
|
||||
{
|
||||
var id = await sender.Send(command);
|
||||
return Results.Ok(id);
|
||||
})
|
||||
.WithName("CreateCategory")
|
||||
.WithSummary("Создать категорию (Admin)");
|
||||
|
||||
catalogGroup.MapGet("/categories", async (ISender sender) =>
|
||||
{
|
||||
var result = await sender.Send(new GetCategoriesQuery());
|
||||
return Results.Ok(result);
|
||||
})
|
||||
.WithName("GetCategories")
|
||||
.WithSummary("Получить все категории (плоский список с ParentId)");
|
||||
|
||||
// --- Услуги (Offers) ---
|
||||
|
||||
catalogGroup.MapPost("/offers", async ([FromBody] CreateOfferCommand command, ISender sender) =>
|
||||
{
|
||||
var id = await sender.Send(command);
|
||||
return Results.Ok(id);
|
||||
})
|
||||
.WithName("CreateOffer")
|
||||
.WithSummary("Создать оффер/услугу");
|
||||
|
||||
catalogGroup.MapGet("/offers/{id:guid}", async (Guid id, ISender sender) =>
|
||||
{
|
||||
var result = await sender.Send(new GetOfferByIdQuery(id));
|
||||
return result is not null ? Results.Ok(result) : Results.NotFound();
|
||||
})
|
||||
.WithName("GetOfferById")
|
||||
.WithSummary("Получить детали услуги по ID");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user