This commit is contained in:
Tizian.Breuch
2025-07-22 17:09:38 +02:00
parent 5568574d9c
commit 0cbf088747
16 changed files with 429 additions and 57 deletions

View File

@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Mvc;
using Webshop.Application.DTOs; // ProductDto
using Webshop.Application.Services.Public; // ProductCatalogService
using Microsoft.AspNetCore.Authorization;
namespace Webshop.Api.Controllers.Public // Beachten Sie den Namespace
{
[ApiController]
[Route("api/v1/public/[controller]")] // z.B. /api/v1/public/products
[AllowAnonymous] // Jeder darf hier zugreifen (Gast oder eingeloggter User)
public class ProductsController : ControllerBase
{
private readonly ProductService _productCatalogService; // Umbenannt
public ProductsController(ProductService productCatalogService) // Injiziert den umbenannten Service
{
_productCatalogService = productCatalogService;
}
[HttpGet] // /api/v1/public/products
public async Task<ActionResult<IEnumerable<ProductDto>>> GetAllProducts()
{
var products = await _productCatalogService.GetAllProductsAsync(); // Ruft Service-Methode auf
return Ok(products);
}
// Keine POST, PUT, DELETE hier für öffentliche Zugriffe.
// Diese gehören in den AdminProductsController.
}
}