Seeding, cleanup, fix nginx proxying

This commit is contained in:
lumijiez
2025-06-09 23:54:37 +03:00
parent c2c4b739f1
commit dd7eeb9eea
32 changed files with 439 additions and 240 deletions

View File

@@ -1,66 +1,23 @@
using Imprink.Application.Products.Create;
using Imprink.Application.Products.Delete;
using Imprink.Application.Products;
using Imprink.Application.Products.Dtos;
using Imprink.Application.Products.Query;
using Imprink.Domain.Common.Models;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Imprink.WebApi.Controllers;
[ApiController]
[Route("api/[controller]")]
[Route("/api/products")]
public class ProductsController(IMediator mediator) : ControllerBase
{
[HttpGet]
[AllowAnonymous]
public async Task<ActionResult<PagedResultDto<ProductDto>>> GetProducts(
[FromQuery] int pageNumber = 1,
[FromQuery] int pageSize = 10,
[FromQuery] string? searchTerm = null,
[FromQuery] Guid? categoryId = null,
[FromQuery] decimal? minPrice = null,
[FromQuery] decimal? maxPrice = null,
[FromQuery] bool? isActive = true,
[FromQuery] bool? isCustomizable = null,
[FromQuery] string sortBy = "Name",
[FromQuery] string sortDirection = "ASC")
[FromQuery] ProductFilterParameters filterParameters)
{
var filterParameters = new ProductFilterParameters
{
PageNumber = pageNumber,
PageSize = pageSize,
SearchTerm = searchTerm,
CategoryId = categoryId,
MinPrice = minPrice,
MaxPrice = maxPrice,
IsActive = isActive,
IsCustomizable = isCustomizable,
SortBy = sortBy,
SortDirection = sortDirection
};
var query = new GetProductsQuery { FilterParameters = filterParameters };
var result = await mediator.Send(query);
var result = await mediator.Send(new GetProductsQuery { FilterParameters = filterParameters });
return Ok(result);
}
[HttpPost]
public async Task<ActionResult<ProductDto>> CreateProduct([FromBody] CreateProductCommand command)
{
var result = await mediator.Send(command);
return CreatedAtAction(nameof(CreateProduct), new { id = result.Id }, result);
}
[HttpDelete("{id:guid}")]
public async Task<ActionResult> DeleteProduct(Guid id)
{
var command = new DeleteProductCommand { Id = id };
var result = await mediator.Send(command);
if (!result)
return NotFound();
return NoContent();
}
}