Skip to content

Commit

Permalink
feature produtos mais vendidos
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunobento1990 committed Feb 24, 2024
1 parent 74311eb commit b4a3638
Show file tree
Hide file tree
Showing 26 changed files with 342 additions and 259 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Mensageria.Domain.Interfaces;

public interface IConfiguracaoParceiroRepository
{
Task<string> GetConnectionStringParceiroAsync(string referer);
}
10 changes: 10 additions & 0 deletions Mensageria/Domain/Interfaces/IProdutosMaisVendidosRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Domain.Pkg.Entities;

namespace Mensageria.Domain.Interfaces;

public interface IProdutosMaisVendidosRepository
{
Task AddRangeAsync(IList<ProdutosMaisVendidos> produtosMaisVendidos, string referer);
Task UpdateRangeAsync(IList<ProdutosMaisVendidos> produtosMaisVendidos, string referer);
Task<IList<ProdutosMaisVendidos>> GetProdutosMaisVendidosAsync(IList<Guid> produtosIds, string referer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Mensageria.Dtos.ProdutosMaisVendidos;

public class AddOrUpdateProdutosMaisVendidosDto
{
public Guid ProdutoId { get; set; }
public decimal QuantidadeProdutos { get; set; }
}
21 changes: 0 additions & 21 deletions Mensageria/Entities/BaseEntity.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Mensageria/Entities/BaseItens.cs

This file was deleted.

20 changes: 0 additions & 20 deletions Mensageria/Entities/Categoria.cs

This file was deleted.

41 changes: 0 additions & 41 deletions Mensageria/Entities/ItensPedido.cs

This file was deleted.

31 changes: 0 additions & 31 deletions Mensageria/Entities/Pedido.cs

This file was deleted.

19 changes: 0 additions & 19 deletions Mensageria/Entities/Peso.cs

This file was deleted.

33 changes: 0 additions & 33 deletions Mensageria/Entities/Produto.cs

This file was deleted.

32 changes: 0 additions & 32 deletions Mensageria/Entities/ProdutosMaisVendidos.cs

This file was deleted.

19 changes: 0 additions & 19 deletions Mensageria/Entities/Tamanho.cs

This file was deleted.

29 changes: 0 additions & 29 deletions Mensageria/Entities/Usuario.cs

This file was deleted.

11 changes: 11 additions & 0 deletions Mensageria/Infra/Context/OpenAdmContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Domain.Pkg.Entities;
using Microsoft.EntityFrameworkCore;

namespace Mensageria.Infra.Context;

public class OpenAdmContext(DbContextOptions<OpenAdmContext> options)
: DbContext(options)
{
public DbSet<Parceiro> Parceiros { get; set; }
public DbSet<ConfiguracaoParceiro> ConfiguracoesParceiro { get; set; }
}
25 changes: 25 additions & 0 deletions Mensageria/Infra/Context/ParceiroContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Domain.Pkg.Entities;
using Microsoft.EntityFrameworkCore;

namespace Mensageria.Infra.Context;

public class ParceiroContext(DbContextOptions options)
: DbContext(options)
{
public DbSet<Banner> Banners { get; set; }
public DbSet<Funcionario> Funcionarios { get; set; }
public DbSet<Categoria> Categorias { get; set; }
public DbSet<Peso> Pesos { get; set; }
public DbSet<Tamanho> Tamanhos { get; set; }
public DbSet<Produto> Produtos { get; set; }
public DbSet<PesosProdutos> PesosProdutos { get; set; }
public DbSet<TamanhosProdutos> TamanhosProdutos { get; set; }
public DbSet<Usuario> Usuarios { get; set; }
public DbSet<Pedido> Pedidos { get; set; }
public DbSet<ItensPedido> ItensPedidos { get; set; }
public DbSet<TabelaDePreco> TabelaDePreco { get; set; }
public DbSet<ItensTabelaDePreco> ItensTabelaDePreco { get; set; }
public DbSet<ProdutosMaisVendidos> ProdutosMaisVendidos { get; set; }
public DbSet<ConfiguracaoDeEmail> ConfiguracoesDeEmail { get; set; }
public DbSet<ConfiguracoesDePedido> ConfiguracoesDePedidos { get; set; }
}
27 changes: 27 additions & 0 deletions Mensageria/Infra/Factories/FactoryParceiroContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Mensageria.Domain.Interfaces;
using Mensageria.Infra.Context;
using Mensageria.Infra.Interfaces;
using Microsoft.EntityFrameworkCore;

namespace Mensageria.Infra.Factories;

public class FactoryParceiroContext : IFactoryParceiroContext
{
private readonly IConfiguracaoParceiroRepository _configuracaoParceiroRepository;

public FactoryParceiroContext(IConfiguracaoParceiroRepository configuracaoParceiroRepository)
{
_configuracaoParceiroRepository = configuracaoParceiroRepository;
}

public async Task<ParceiroContext> CreateParceiroContextAsync(string referer)
{
var connectionString = await _configuracaoParceiroRepository.GetConnectionStringParceiroAsync(referer);

var optionsBuilderParceiro = new DbContextOptionsBuilder<ParceiroContext>();

optionsBuilderParceiro.UseNpgsql(connectionString);

return new ParceiroContext(optionsBuilderParceiro.Options);
}
}
8 changes: 8 additions & 0 deletions Mensageria/Infra/Interfaces/IFactoryParceiroContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Mensageria.Infra.Context;

namespace Mensageria.Infra.Interfaces;

public interface IFactoryParceiroContext
{
Task<ParceiroContext> CreateParceiroContextAsync(string referer);
}
26 changes: 26 additions & 0 deletions Mensageria/Infra/Repositories/ConfiguracaoParceiroRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Mensageria.Domain.Interfaces;
using Mensageria.Infra.Context;
using Microsoft.EntityFrameworkCore;

namespace Mensageria.Infra.Repositories;

public class ConfiguracaoParceiroRepository : IConfiguracaoParceiroRepository
{
private readonly OpenAdmContext _openAdmContext;

public ConfiguracaoParceiroRepository(OpenAdmContext openAdmContext)
{
_openAdmContext = openAdmContext;
}

public async Task<string> GetConnectionStringParceiroAsync(string referer)
{
return await _openAdmContext
.ConfiguracoesParceiro
.AsNoTracking()
.Where(x => x.DominioSiteAdm == referer || x.DominioSiteEcommerce == referer)
.Select(x => x.ConexaoDb)
.FirstOrDefaultAsync()
?? throw new Exception("Conexão do parceiro não foi localizada!");
}
}
Loading

0 comments on commit b4a3638

Please sign in to comment.