controler aufräumen

This commit is contained in:
Tizian.Breuch
2025-08-01 10:22:05 +02:00
parent 0b35597347
commit 38085ef199
11 changed files with 16 additions and 16 deletions

View File

@@ -10,7 +10,7 @@ using Webshop.Application.Services.Admin;
namespace Webshop.Api.Controllers.Admin namespace Webshop.Api.Controllers.Admin
{ {
[ApiController] [ApiController]
[Route("api/v1/admin/categorys")] [Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")] [Authorize(Roles = "Admin")]
public class AdminCategorysController : ControllerBase public class AdminCategorysController : ControllerBase
{ {

View File

@@ -11,7 +11,7 @@ using Webshop.Domain.Enums;
namespace Webshop.Api.Controllers.Admin namespace Webshop.Api.Controllers.Admin
{ {
[ApiController] [ApiController]
[Route("api/v1/admin/orders")] [Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")] [Authorize(Roles = "Admin")]
public class AdminOrdersController : ControllerBase public class AdminOrdersController : ControllerBase
{ {

View File

@@ -10,7 +10,7 @@ using Webshop.Application.Services.Admin; // IAdminPaymentMethodService
namespace Webshop.Api.Controllers.Admin namespace Webshop.Api.Controllers.Admin
{ {
[ApiController] [ApiController]
[Route("api/v1/admin/paymentmethods")] // Saubere Route [Route("api/v1/admin/[controller]")] // Saubere Route
[Authorize(Roles = "Admin")] // Nur Admins [Authorize(Roles = "Admin")] // Nur Admins
public class AdminPaymentMethodsController : ControllerBase public class AdminPaymentMethodsController : ControllerBase
{ {

View File

@@ -10,7 +10,7 @@ using Webshop.Application.Services.Admin;
namespace Webshop.Api.Controllers.Admin namespace Webshop.Api.Controllers.Admin
{ {
[ApiController] [ApiController]
[Route("api/v1/admin/shippingmethods")] [Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")] [Authorize(Roles = "Admin")]
public class AdminShippingMethodsController : ControllerBase public class AdminShippingMethodsController : ControllerBase
{ {

View File

@@ -11,7 +11,7 @@ using Webshop.Application.Services.Customers;
namespace Webshop.Api.Controllers.Customer namespace Webshop.Api.Controllers.Customer
{ {
[ApiController] [ApiController]
[Route("api/v1/customer/addresses")] [Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")] [Authorize(Roles = "Customer")]
public class AddressesController : ControllerBase public class AddressesController : ControllerBase
{ {

View File

@@ -15,7 +15,7 @@ namespace Webshop.Api.Controllers.Customer
{ {
[ApiController] [ApiController]
[Route("api/v1/[controller]")] // z.B. /api/v1/customer/profile [Route("api/v1/customer/[controller]")] // z.B. /api/v1/customer/profile
[Authorize(Roles = "Customer")] [Authorize(Roles = "Customer")]
public class CustomerController : ControllerBase public class CustomerController : ControllerBase
{ {

View File

@@ -12,7 +12,7 @@ using Webshop.Application.Services.Customers.Interfaces; // Für IOrderService
namespace Webshop.Api.Controllers.Customer namespace Webshop.Api.Controllers.Customer
{ {
[ApiController] [ApiController]
[Route("api/v1/customer/orders")] [Route("api/v1/customer/[controller]")]
[Authorize(Roles = "Customer")] [Authorize(Roles = "Customer")]
public class OrdersController : ControllerBase public class OrdersController : ControllerBase
{ {

View File

@@ -9,7 +9,7 @@ using Webshop.Application.Services.Public;
namespace Webshop.Api.Controllers.Public namespace Webshop.Api.Controllers.Public
{ {
[ApiController] [ApiController]
[Route("api/v1/public/categorys")] [Route("api/v1/public/[controller]")]
[AllowAnonymous] [AllowAnonymous]
public class CategoryController : ControllerBase public class CategoryController : ControllerBase
{ {

View File

@@ -9,7 +9,7 @@ using Webshop.Application.Services.Public; // IPaymentMethodService
namespace Webshop.Api.Controllers.Public namespace Webshop.Api.Controllers.Public
{ {
[ApiController] [ApiController]
[Route("api/v1/public/paymentmethods")] // Saubere Route [Route("api/v1/public/[controller]")] // Saubere Route
[AllowAnonymous] // Jeder darf die verfügbaren Zahlungsmethoden sehen [AllowAnonymous] // Jeder darf die verfügbaren Zahlungsmethoden sehen
public class PaymentMethodsController : ControllerBase public class PaymentMethodsController : ControllerBase
{ {

View File

@@ -9,7 +9,7 @@ using Webshop.Application.Services.Public.Interfaces; // <-- WICHTIGES USING HIN
namespace Webshop.Api.Controllers.Public namespace Webshop.Api.Controllers.Public
{ {
[ApiController] [ApiController]
[Route("api/v1/public/products")] // Route explizit gemacht f<>r Klarheit [Route("api/v1/public/[controller]")] // Route explizit gemacht f<>r Klarheit
[AllowAnonymous] [AllowAnonymous]
public class ProductsController : ControllerBase public class ProductsController : ControllerBase
{ {

View File

@@ -138,18 +138,18 @@ builder.Services.AddSwaggerGen(c =>
} }
var tag = controllerName.Replace("Admin", "").Replace("Controller", ""); // Entfernt Pr<50>fixe/Suffixe var tag = controllerName.Replace("Admin", "").Replace("Controller", ""); // Entfernt Pr<50>fixe/Suffixe
// Erkenne den Hauptbereich anhand des Routen-Pr<50>fixes
if (api.RelativePath.StartsWith("api/v1/admin"))
{
// Erzeugt einen Tag wie "Admin - Products", "Admin - Users" etc.
return new[] { $"Admin - {tag}" };
}
if (api.RelativePath.StartsWith("api/v1/auth")) if (api.RelativePath.StartsWith("api/v1/auth"))
{ {
// Auth hat normalerweise nur einen Controller, daher keine Untergruppe // Auth hat normalerweise nur einen Controller, daher keine Untergruppe
return new[] { "Auth" }; return new[] { "Auth" };
} }
// Erkenne den Hauptbereich anhand des Routen-Pr<50>fixes
if (api.RelativePath.StartsWith("api/v1/admin"))
{
// Erzeugt einen Tag wie "Admin - Products", "Admin - Users" etc.
return new[] { $"Admin - {tag}" };
}
if (api.RelativePath.StartsWith("api/v1/customer")) if (api.RelativePath.StartsWith("api/v1/customer"))
{ {
// Erzeugt einen Tag wie "Customer - Profile", "Customer - Orders" // Erzeugt einen Tag wie "Customer - Profile", "Customer - Orders"