Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #30

Merged
merged 4 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions OpenAdm.Api/Attributes/AutenticaParceiroAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace OpenAdm.Api.Attributes;

public class AutenticaParceiroAttribute : Attribute
{
}
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/BannerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("banners")]
[AutenticaParceiro]
public class BannerController(IBannerService bannerService) : ControllerBase
{
private readonly IBannerService _bannerService = bannerService;
Expand Down
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/Carrinhos/AddCarrinhoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace OpenAdm.Api.Controllers.Carrinhos;
[ApiController]
[Route("carrinho")]
[Autentica]
[AutenticaParceiro]
public class AddCarrinhoController : ControllerBase
{
private readonly IAddCarrinhoService _addCarrinhoSerice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace OpenAdm.Api.Controllers.Carrinhos;
[ApiController]
[Route("carrinho")]
[Autentica]
[AutenticaParceiro]
public class CoutCarrinhoController : ControllerBase
{
private readonly IGetCountCarrinhoService _carrinhoService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Interfaces;
using OpenAdm.Application.Interfaces.Carrinhos;
using OpenAdm.Domain.Interfaces;

Expand All @@ -9,6 +8,7 @@ namespace OpenAdm.Api.Controllers.Carrinhos;
[ApiController]
[Route("carrinho")]
[Autentica]
[AutenticaParceiro]
public class DeleteProdutoCarrinhoController : ControllerBase
{
private readonly IDeleteProdutoCarrinhoService _deleteProdutoCarrinhoService;
Expand Down
2 changes: 1 addition & 1 deletion OpenAdm.Api/Controllers/Carrinhos/GetCarrinhoController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Interfaces;
using OpenAdm.Application.Interfaces.Carrinhos;
using OpenAdm.Application.Models.Usuarios;
using OpenAdm.Domain.Interfaces;
Expand All @@ -10,6 +9,7 @@ namespace OpenAdm.Api.Controllers.Carrinhos;
[ApiController]
[Route("carrinho")]
[Autentica]
[AutenticaParceiro]
public class GetCarrinhoController : ControllerBase
{
private readonly IGetCarrinhoService _getCarrinhoService;
Expand Down
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/CategoriaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("categorias")]
[AutenticaParceiro]
public class CategoriaController(ICategoriaService categoriaService)
: ControllerBase
{
Expand Down
42 changes: 0 additions & 42 deletions OpenAdm.Api/Controllers/ConfiguracaoDeFreteController.cs

This file was deleted.

1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/ConfiguracoesDeEmailController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace OpenAdm.Api.Controllers;
[Route("configuracoes-de-email")]
[IsFuncionario]
[Autentica]
[AutenticaParceiro]
public class ConfiguracoesDeEmailController : ControllerBase
{
private readonly IConfiguracoesDeEmailService _configuracoesDeEmailService;
Expand Down
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/ConfiguracoesDePedidoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace OpenAdm.Api.Controllers;
[ApiController]
[Route("configuracoes-de-pedido")]
[Autentica]
[AutenticaParceiro]
public class ConfiguracoesDePedidoController : ControllerBase
{
private readonly IConfiguracoesDePedidoService _configuracoesDePedidoService;
Expand Down
8 changes: 8 additions & 0 deletions OpenAdm.Api/Controllers/CriptController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ public class CriptController : ControllerBase
[HttpPost("Criptar")]
public IActionResult Criptar(BodyCript bodyCript)
{
if (!VariaveisDeAmbiente.IsDevelopment())
{
return Unauthorized();
}
var conn = Criptografia.Encrypt(bodyCript.Code);
return Ok(conn);
}

[HttpPost("DeCriptar")]
public IActionResult DeCriptar(BodyCript bodyCript)
{
if (!VariaveisDeAmbiente.IsDevelopment())
{
return Unauthorized();
}
var conn = Criptografia.Decrypt(bodyCript.Code);
return Ok(conn);
}
Expand Down
2 changes: 2 additions & 0 deletions OpenAdm.Api/Controllers/EsqueceuSenhaController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Dtos.Usuarios;
using OpenAdm.Application.Interfaces;

namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("usuarios")]
[AutenticaParceiro]
public class EsqueceuSenhaController : ControllerBase
{
private readonly IEsqueceuSenhaService _esqueceuSenhaService;
Expand Down
12 changes: 5 additions & 7 deletions OpenAdm.Api/Controllers/EstoqueController.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using Domain.Pkg.Errors;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Dtos.Estoques;
using OpenAdm.Application.Interfaces;
using OpenAdm.Application.Services;
using OpenAdm.Infra.Paginacao;

namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("estoques")]
[Autentica]
[IsFuncionario]
[Route("estoques")]
[AutenticaParceiro]
public class EstoqueController : ControllerBase
{
private readonly IEstoqueService _estoqueservice;
Expand All @@ -27,7 +25,7 @@ public async Task<IActionResult> MovimentarEstoque(MovimentacaoDeProdutoDto movi
{
var result = await _estoqueservice.MovimentacaoDeProdutoAsync(movimentacaoDeProduto);

if (!result) return BadRequest(new { message = CodigoErrors.ErrorGeneric });
if (!result) return BadRequest(new { message = "Ocorreu um erro, tente novamente" });

return Ok();
}
Expand All @@ -44,7 +42,7 @@ public async Task<IActionResult> UpdateEstoque(UpdateEstoqueDto updateEstoqueDto
{
var result = await _estoqueservice.UpdateEstoqueAsync(updateEstoqueDto);

if (!result) return BadRequest(new { message = CodigoErrors.ErrorGeneric });
if (!result) return BadRequest(new { message = "Ocorreu um erro, tente novamente" });

return Ok();
}
Expand Down
31 changes: 0 additions & 31 deletions OpenAdm.Api/Controllers/FreteController.cs

This file was deleted.

4 changes: 3 additions & 1 deletion OpenAdm.Api/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Interfaces;

namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("home")]
[AutenticaParceiro]
public class HomeController : ControllerBase
{
private readonly IHomeSevice _homeEcommerSevice;
Expand All @@ -14,7 +16,7 @@ public HomeController(IHomeSevice homeEcommerSevice)
_homeEcommerSevice = homeEcommerSevice;
}

//[ResponseCache(CacheProfileName = "Default300")]
[ResponseCache(CacheProfileName = "Default300")]
[HttpGet("adm")]
public async Task<IActionResult> ListAdm()
{
Expand Down
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/ItemTabelaDePrecoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace OpenAdm.Api.Controllers;
[Route("item-tabela-de-preco")]
[Autentica]
[IsFuncionario]
[AutenticaParceiro]
public class ItemTabelaDePrecoController : ControllerBase
{
private readonly IItemTabelaDePrecoService _itemTabelaDePrecoService;
Expand Down
7 changes: 3 additions & 4 deletions OpenAdm.Api/Controllers/ItensPedidoController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Domain.Pkg.Errors;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Dtos.ItensPedidos;
using OpenAdm.Application.Interfaces;
Expand All @@ -10,6 +8,7 @@ namespace OpenAdm.Api.Controllers;
[ApiController]
[Route("itens-pedidos")]
[Autentica]
[AutenticaParceiro]
public class ItensPedidoController : ControllerBase
{
private readonly IItensPedidoService _itensPedidoService;
Expand All @@ -32,7 +31,7 @@ public async Task<IActionResult> DeleteItem([FromQuery] Guid id)
var result = await _itensPedidoService.DeleteItemPedidoAsync(id);
if (!result)
{
return BadRequest(new { message = CodigoErrors.ErrorGeneric });
return BadRequest(new { message = "Ocorreu um erro, tente novamente" });
}
return Ok();
}
Expand Down
2 changes: 2 additions & 0 deletions OpenAdm.Api/Controllers/LoginController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Interfaces;
using OpenAdm.Application.Models.Logins;

namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("login")]
[AutenticaParceiro]
public class LoginController : ControllerBase
{
private readonly ILoginFuncionarioService _loginFuncionarioService;
Expand Down
6 changes: 3 additions & 3 deletions OpenAdm.Api/Controllers/LojasParceirasController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Dtos.LojaParceira;
using OpenAdm.Application.Dtos.LojasParceiras;
using OpenAdm.Application.Interfaces;
using OpenAdm.Infra.Paginacao;

namespace OpenAdm.Api.Controllers;

[ApiController]
[Route("lojas-parceiras")]
[AutenticaParceiro]
public class LojasParceirasController : ControllerBase
{
private readonly ILojasParceirasService _lojasParceirasService;
Expand Down
13 changes: 12 additions & 1 deletion OpenAdm.Api/Controllers/MovimentacaoDeProdutoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Dtos.MovimentosDeProdutos;
using OpenAdm.Application.Interfaces;
using OpenAdm.Infra.Paginacao;

Expand All @@ -9,10 +10,10 @@ namespace OpenAdm.Api.Controllers;
[Route("movimentacao-de-produto")]
[Autentica]
[IsFuncionario]
[AutenticaParceiro]
public class MovimentacaoDeProdutoController : ControllerBase
{
private readonly IMovimentacaoDeProdutosService _movimentacaoDeProdutosService;

public MovimentacaoDeProdutoController(IMovimentacaoDeProdutosService movimentacaoDeProdutosService)
{
_movimentacaoDeProdutosService = movimentacaoDeProdutosService;
Expand All @@ -24,4 +25,14 @@ public async Task<IActionResult> Paginacao([FromQuery] PaginacaoMovimentacaoDePr
var paginacao = await _movimentacaoDeProdutosService.GetPaginacaoAsync(paginacaoMovimentacaoDeProdutoDto);
return Ok(paginacao);
}

[HttpPost("relatorio")]
public async Task<IActionResult> Relatorio(RelatorioMovimentoDeProdutoDto relatorioMovimentoDeProdutoDto)
{
var pdf = await _movimentacaoDeProdutosService.GerarRelatorioAsync(relatorioMovimentoDeProdutoDto);
return Ok(new
{
pdf
});
}
}
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/PedidoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace OpenAdm.Api.Controllers;
[ApiController]
[Route("pedidos")]
[Autentica]
[AutenticaParceiro]
public class PedidoController : ControllerBase
{
private readonly IPedidoService _pedidoService;
Expand Down
7 changes: 4 additions & 3 deletions OpenAdm.Api/Controllers/Pedidos/CreatePedidoController.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Domain.Pkg.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using OpenAdm.Api.Attributes;
using OpenAdm.Application.Interfaces.Pedidos;
using OpenAdm.Domain.Interfaces;
using OpenAdm.Domain.Model.Pedidos;

namespace OpenAdm.Api.Controllers.Pedidos;

[ApiController]
[Route("pedidos")]
[Autentica]
[AutenticaParceiro]
public class CreatePedidoController : ControllerBase
{
private readonly ICreatePedidoService _createPedidoService;
Expand All @@ -23,7 +24,7 @@ public CreatePedidoController(
}

[HttpPost("create")]
public async Task<IActionResult> CreatePedido(IList<ItensPedidoModel> itensPedidoModels)
public async Task<IActionResult> CreatePedido(IList<ItemPedidoModel> itensPedidoModels)
{
var usuario = await _usuarioAutenticado.GetUsuarioAutenticadoAsync();
var result = await _createPedidoService.CreatePedidoAsync(itensPedidoModels, usuario);
Expand Down
1 change: 1 addition & 0 deletions OpenAdm.Api/Controllers/Pedidos/DeletePedidoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace OpenAdm.Api.Controllers.Pedidos;
[Route("pedidos")]
[Autentica]
[IsFuncionario]
[AutenticaParceiro]
public class DeletePedidoController : ControllerBase
{
private readonly IDeletePedidoService _deletePedidoService;
Expand Down
Loading
Loading