-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53bf889
commit 9f7ed55
Showing
42 changed files
with
897 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using OpenAdm.Application.Dtos.Usuarios; | ||
using OpenAdm.Application.Interfaces; | ||
|
||
namespace OpenAdm.Api.Controllers; | ||
|
||
[ApiController] | ||
[Route("usuarios")] | ||
public class EsqueceuSenhaController : ControllerBaseApi | ||
{ | ||
private readonly IEsqueceuSenhaService _esqueceuSenhaService; | ||
|
||
public EsqueceuSenhaController(IEsqueceuSenhaService esqueceuSenhaService) | ||
{ | ||
_esqueceuSenhaService = esqueceuSenhaService; | ||
} | ||
|
||
[HttpPut("esqueceu-senha")] | ||
public async Task<IActionResult> ResetarSenha(EsqueceuSenhaDto esqueceuSenhaDto) | ||
{ | ||
try | ||
{ | ||
await _esqueceuSenhaService.EsqueceuSenhaAsync(esqueceuSenhaDto); | ||
return Ok(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using OpenAdm.Application.Interfaces; | ||
|
||
namespace OpenAdm.Api.Controllers; | ||
|
||
[ApiController] | ||
[Route("itens-pedidos")] | ||
[Authorize(AuthenticationSchemes = "Bearer")] | ||
public class ItensPedidoController : ControllerBaseApi | ||
{ | ||
private readonly IItensPedidoService _itensPedidoService; | ||
|
||
public ItensPedidoController(IItensPedidoService itensPedidoService) | ||
{ | ||
_itensPedidoService = itensPedidoService; | ||
} | ||
|
||
[HttpGet("get-pedido-id")] | ||
public async Task<IActionResult> GetByPedido([FromQuery] Guid pedidoId) | ||
{ | ||
try | ||
{ | ||
var itens = await _itensPedidoService.GetItensPedidoByPedidoIdAsync(pedidoId); | ||
return Ok(itens); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using OpenAdm.Application.Dtos.Usuarios; | ||
using OpenAdm.Application.Interfaces; | ||
using OpenAdm.Application.Models.Tokens; | ||
|
||
namespace OpenAdm.Api.Controllers; | ||
|
||
[ApiController] | ||
[Route("usuarios")] | ||
public class UsuarioController : ControllerBaseApi | ||
{ | ||
private readonly IUsuarioService _usuarioService; | ||
private readonly ConfiguracaoDeToken _configGenerateToken; | ||
|
||
public UsuarioController(IUsuarioService usuarioService) | ||
{ | ||
var key = VariaveisDeAmbiente.GetVariavel("JWT_KEY"); | ||
var issue = VariaveisDeAmbiente.GetVariavel("JWT_ISSUE"); | ||
var audience = VariaveisDeAmbiente.GetVariavel("JWT_AUDIENCE"); | ||
var expirate = DateTime.Now.AddHours(int.Parse(VariaveisDeAmbiente.GetVariavel("JWT_EXPIRATION"))); | ||
_configGenerateToken = new ConfiguracaoDeToken(key, issue, audience, expirate); | ||
_usuarioService = usuarioService; | ||
} | ||
|
||
[Authorize(AuthenticationSchemes = "Bearer")] | ||
[HttpGet("get-conta")] | ||
public async Task<IActionResult> GetConta() | ||
{ | ||
try | ||
{ | ||
var usuarioViewModel = await _usuarioService.GetUsuarioByIdAsync(); | ||
return Ok(usuarioViewModel); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
|
||
[Authorize(AuthenticationSchemes = "Bearer")] | ||
[HttpPut("update")] | ||
public async Task<IActionResult> UpdateUsuario(UpdateUsuarioDto updateUsuarioDto) | ||
{ | ||
try | ||
{ | ||
var result = await _usuarioService.UpdateUsuarioAsync(updateUsuarioDto, _configGenerateToken); | ||
|
||
return Ok(result); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return await HandleErrorAsync(ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace OpenAdm.Application.Dtos.Usuarios; | ||
|
||
public class EsqueceuSenhaDto | ||
{ | ||
[Required] | ||
[MaxLength(255)] | ||
[DataType(DataType.EmailAddress)] | ||
public string Email { get; set; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace OpenAdm.Application.Dtos.Usuarios; | ||
|
||
public class UpdateUsuarioDto | ||
{ | ||
[Required] | ||
[MaxLength(255)] | ||
public string Nome { get; set; } = string.Empty; | ||
[Required] | ||
[MaxLength(255)] | ||
[DataType(DataType.EmailAddress)] | ||
public string Email { get; set; } = string.Empty; | ||
[MaxLength(15)] | ||
public string? Telefone { get; set; } | ||
[MaxLength(20)] | ||
public string? Cnpj { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using OpenAdm.Application.Models.Emails; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface IEmailService | ||
{ | ||
Task<bool> SendEmail(EnvioEmailModel envioEmailModel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using OpenAdm.Application.Dtos.Usuarios; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface IEsqueceuSenhaService | ||
{ | ||
Task<bool> EsqueceuSenhaAsync(EsqueceuSenhaDto esqueceuSenhaDto); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using OpenAdm.Application.Models.Pedidos; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface IItensPedidoService | ||
{ | ||
Task<IList<ItensPedidoViewModel>> GetItensPedidoByPedidoIdAsync(Guid pedidoId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using OpenAdm.Application.Dtos.Usuarios; | ||
using OpenAdm.Application.Models.Logins; | ||
using OpenAdm.Application.Models.Tokens; | ||
using OpenAdm.Application.Models.Usuarios; | ||
|
||
namespace OpenAdm.Application.Interfaces; | ||
|
||
public interface IUsuarioService | ||
{ | ||
Task<UsuarioViewModel> GetUsuarioByIdAsync(); | ||
Task<ResponseLoginUsuarioViewModel> UpdateUsuarioAsync(UpdateUsuarioDto updateUsuarioDto, ConfiguracaoDeToken configuracaoDeToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace OpenAdm.Application.Models.Emails; | ||
|
||
public class EnvioEmailModel | ||
{ | ||
public string Email { get; set; } = string.Empty; | ||
public string Mensagem { get; set; } = string.Empty; | ||
public string Assunto { get; set; } = string.Empty; | ||
public string? NomeDoArquivo { get; set; } | ||
public string? TipoDoArquivo { get; set; } | ||
public byte[]? Arquivo { get; set; } | ||
} |
47 changes: 47 additions & 0 deletions
47
OpenAdm.Application/Models/Pedidos/ItensPedidoViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using OpenAdm.Application.Models.Pesos; | ||
using OpenAdm.Application.Models.Produtos; | ||
using OpenAdm.Application.Models.Tamanhos; | ||
using OpenAdm.Domain.Entities; | ||
|
||
namespace OpenAdm.Application.Models.Pedidos; | ||
|
||
public class ItensPedidoViewModel : BaseModel | ||
{ | ||
public Guid? PesoId { get; set; } | ||
public PesoViewModel? Peso { get; set; } | ||
public Guid? TamanhoId { get; set; } | ||
public TamanhoViewModel? Tamanho { get; set; } | ||
public Guid ProdutoId { get; set; } | ||
public ProdutoViewModel Produto { get; set; } = null!; | ||
public Guid PedidoId { get; set; } | ||
public decimal ValorUnitario { get; set; } | ||
public decimal Quantidade { get; set; } | ||
public decimal ValorTotal { get; set; } | ||
public ItensPedidoViewModel ToModel(ItensPedido entity) | ||
{ | ||
Id = entity.Id; | ||
DataDeCriacao = entity.DataDeCriacao; | ||
Numero = entity.Numero; | ||
PesoId = entity.PesoId; | ||
TamanhoId = entity.TamanhoId; | ||
ProdutoId = entity.ProdutoId; | ||
PedidoId = entity.PedidoId; | ||
|
||
if (entity.Peso != null) | ||
{ | ||
Peso = new PesoViewModel().ToModel(entity.Peso); | ||
} | ||
|
||
if (entity.Tamanho != null) | ||
{ | ||
Tamanho = new TamanhoViewModel().ToModel(entity.Tamanho); | ||
} | ||
|
||
Produto = new ProdutoViewModel().ToModel(entity.Produto) ?? new(); | ||
ValorUnitario = entity.ValorUnitario; | ||
ValorTotal = entity.ValorTotal; | ||
Quantidade = entity.Quantidade; | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using OpenAdm.Application.Models; | ||
using OpenAdm.Domain.Entities; | ||
|
||
namespace OpenAdm.Application.Models.Pesos; | ||
|
||
public class PesoViewModel : BaseModel | ||
{ | ||
public string Descricao { get; set; } = string.Empty; | ||
|
||
public PesoViewModel ToModel(Peso entity) | ||
{ | ||
Id = entity.Id; | ||
Descricao = entity.Descricao; | ||
DataDeCriacao = entity.DataDeCriacao; | ||
DataDeAtualizacao = entity.DataDeAtualizacao; | ||
Numero = entity.Numero; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.