dtos neu und aufräumen
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Webshop.Application.DTOs.Auth;
|
||||
using Webshop.Application.DTOs.Email;
|
||||
using Webshop.Application.Services.Auth;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@@ -14,12 +15,6 @@ namespace Webshop.Api.Controllers.Auth // Beachten Sie den Namespace
|
||||
private readonly IAuthService _authService;
|
||||
private readonly ICustomerService _customerService;
|
||||
|
||||
public class ResendEmailConfirmationRequestDto
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public AuthController(IAuthService authService, ICustomerService customerService)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Security.Claims;
|
||||
using Webshop.Application.DTOs; // CustomerDto
|
||||
using Webshop.Application.DTOs.Auth; // ChangePasswordRequestDto
|
||||
using Webshop.Application.DTOs.Customers; // UpdateCustomerProfileDto
|
||||
using Webshop.Application.DTOs.Email;
|
||||
using Webshop.Application.Services;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.Services.Customers;
|
||||
@@ -12,15 +13,6 @@ using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Webshop.Api.Controllers.Customer
|
||||
{
|
||||
public class ChangeEmailRequestDto
|
||||
{
|
||||
[Required(ErrorMessage = "Neue E-Mail ist erforderlich.")]
|
||||
[EmailAddress(ErrorMessage = "Ung<6E>ltiges E-Mail-Format.")]
|
||||
public string NewEmail { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "Aktuelles Passwort ist erforderlich.")]
|
||||
public string CurrentPassword { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[Route("api/v1/[controller]")] // z.B. /api/v1/customer/profile
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// src/Webshop.Api/SwaggerFilters/AddExampleSchemaFilter.cs
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Webshop.Application.DTOs;
|
||||
using System; // Für Guid.NewGuid()
|
||||
using Webshop.Application.DTOs; // Allgemeine DTOs wie AdminProductDto, ProductDto, SupplierDto
|
||||
using Webshop.Application.DTOs.Auth;
|
||||
using Webshop.Application.DTOs.Users;
|
||||
using System;
|
||||
using Webshop.Application.DTOs.Categorys; // Korrekter Namespace
|
||||
using Webshop.Application.DTOs.Customers;
|
||||
using Webshop.Application.DTOs.Discounts;
|
||||
using Webshop.Application.DTOs.Email; // Für ResendEmailConfirmationRequestDto
|
||||
using Webshop.Application.DTOs.Orders;
|
||||
using Webshop.Application.DTOs.Payments;
|
||||
using Webshop.Application.DTOs.Products;
|
||||
using Webshop.Application.DTOs.Reviews;
|
||||
using Webshop.Application.DTOs.Shipping;
|
||||
using Webshop.Application.DTOs.Suppliers;
|
||||
using Webshop.Application.DTOs.Reviews;
|
||||
using Webshop.Application.DTOs.Products;
|
||||
using Webshop.Application.DTOs.Payments;
|
||||
using Webshop.Application.DTOs.Orders;
|
||||
using Webshop.Application.DTOs.Discounts;
|
||||
using Webshop.Application.DTOs.Categorys;
|
||||
using Webshop.Api.Controllers.Auth;
|
||||
using Webshop.Application.DTOs.Users;
|
||||
using Webshop.Domain.Enums;
|
||||
|
||||
namespace Webshop.Api.SwaggerFilters
|
||||
@@ -25,12 +25,12 @@ namespace Webshop.Api.SwaggerFilters
|
||||
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
||||
{
|
||||
var type = context.Type;
|
||||
// Eine eindeutige Kennung, die wir an SKU/Slug anhängen können
|
||||
var uniqueId = Guid.NewGuid().ToString().Substring(0, 8); // Z.B. 8 Zeichen der GUID
|
||||
var uniqueId = Guid.NewGuid().ToString().Substring(0, 8);
|
||||
|
||||
// --- Authentifizierung & Benutzer (Allgemeine Schemas) ---
|
||||
if (type == typeof(LoginRequestDto))
|
||||
{
|
||||
// Hinweis: Dieses Beispiel wird vom LoginExampleOperationFilter für spezifische Endpunkte überschrieben.
|
||||
schema.Example = new OpenApiObject
|
||||
{
|
||||
["email"] = new OpenApiString("user@example.com"),
|
||||
@@ -41,7 +41,7 @@ namespace Webshop.Api.SwaggerFilters
|
||||
{
|
||||
schema.Example = new OpenApiObject
|
||||
{
|
||||
["email"] = new OpenApiString($"neuer.kunde.{uniqueId}@example.com"), // Eindeutige E-Mail
|
||||
["email"] = new OpenApiString($"neuer.kunde.{uniqueId}@example.com"),
|
||||
["password"] = new OpenApiString("NeuesPasswort123!"),
|
||||
["confirmPassword"] = new OpenApiString("NeuesPasswort123!"),
|
||||
["firstName"] = new OpenApiString("Erika"),
|
||||
@@ -72,11 +72,11 @@ namespace Webshop.Api.SwaggerFilters
|
||||
["emailConfirmed"] = new OpenApiBoolean(true)
|
||||
};
|
||||
}
|
||||
else if (type == typeof(AuthController.ResendEmailConfirmationRequestDto))
|
||||
else if (type == typeof(ResendEmailConfirmationRequestDto)) // DTO verschoben nach Application/DTOs/Email
|
||||
{
|
||||
schema.Example = new OpenApiObject
|
||||
{
|
||||
["email"] = new OpenApiString("me@tzbre.dev")
|
||||
["email"] = new OpenApiString("unconfirmed.user@example.com")
|
||||
};
|
||||
}
|
||||
// --- Produkte & Lieferanten ---
|
||||
@@ -113,7 +113,7 @@ namespace Webshop.Api.SwaggerFilters
|
||||
["slug"] = new OpenApiString($"admin-produkt-beispiel-slug-{uniqueId}"),
|
||||
["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
|
||||
["lastModifiedDate"] = new OpenApiNull(),
|
||||
["supplierId"] = new OpenApiNull(), // ODER new OpenApiString("IHR-ECHTER-LIEFERANTEN-GUID-HIER")
|
||||
["supplierId"] = new OpenApiNull(),
|
||||
["purchasePrice"] = new OpenApiDouble(80.00)
|
||||
};
|
||||
}
|
||||
@@ -209,13 +209,11 @@ namespace Webshop.Api.SwaggerFilters
|
||||
["firstName"] = new OpenApiString("Max"),
|
||||
["lastName"] = new OpenApiString("Mustermann"),
|
||||
["phoneNumber"] = new OpenApiString("+491701234567"),
|
||||
// ["email"] = new OpenApiString($"max.mustermann.neu.{uniqueId}@example.com"), // << ENTFERNT >>
|
||||
["currentPassword"] = new OpenApiString("SecureCustomerPass123!"),
|
||||
["defaultShippingAddressId"] = new OpenApiNull(),
|
||||
["defaultBillingAddressId"] = new OpenApiNull()
|
||||
};
|
||||
}
|
||||
|
||||
// --- Rabatte ---
|
||||
else if (type == typeof(DiscountDto))
|
||||
{
|
||||
@@ -226,13 +224,12 @@ namespace Webshop.Api.SwaggerFilters
|
||||
["description"] = new OpenApiString("10% Rabatt auf alles"),
|
||||
["type"] = new OpenApiString(DiscountType.Percentage.ToString()),
|
||||
["value"] = new OpenApiDouble(10.00),
|
||||
["couponCode"] = new OpenApiString($"SOMMER-{uniqueId}"), // Optional, muss eindeutig sein
|
||||
["couponCode"] = new OpenApiString($"SOMMER-{uniqueId}"),
|
||||
["startDate"] = new OpenApiString(DateTimeOffset.UtcNow.AddDays(1).ToString("o")),
|
||||
["endDate"] = new OpenApiString(DateTimeOffset.UtcNow.AddDays(30).ToString("o")),
|
||||
["isActive"] = new OpenApiBoolean(true),
|
||||
["maxUses"] = new OpenApiInteger(100),
|
||||
["currentUses"] = new OpenApiInteger(0),
|
||||
["description"] = new OpenApiString("Gültig vom 1. September bis 30. September.")
|
||||
["currentUses"] = new OpenApiInteger(0)
|
||||
};
|
||||
}
|
||||
// --- Bestellungen ---
|
||||
@@ -334,7 +331,7 @@ namespace Webshop.Api.SwaggerFilters
|
||||
{
|
||||
schema.Example = new OpenApiObject
|
||||
{
|
||||
["key"] = new OpenApiString($"GlobalTaxRate-{uniqueId}"), // Für POST: Muss eindeutig sein
|
||||
["key"] = new OpenApiString($"GlobalTaxRate-{uniqueId}"),
|
||||
["value"] = new OpenApiString("0.19"),
|
||||
["description"] = new OpenApiString("Allgemeiner Mehrwertsteuersatz"),
|
||||
["lastModifiedDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o"))
|
||||
|
||||
Reference in New Issue
Block a user