Skip to content

Commit c79fe0c

Browse files
committed
#241 - Modelar as classes de pagamento - feature/sp7/#241
1 parent caad81c commit c79fe0c

36 files changed

+1139
-60
lines changed

JS.Enterprise.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pedido", "Pedido", "{856468
3131
EndProject
3232
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Carrinho.API", "src\services\JSE.Carrinho.API\JSE.Carrinho.API.csproj", "{D3FFF619-CBFD-4472-BA95-093C058BCB40}"
3333
EndProject
34-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Pagamento.API", "src\services\JSE.Pagamento.API\JSE.Pagamento.API.csproj", "{6CBCEEF0-45E1-4050-9745-556ED2C4BDC9}"
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Pagamentos.API", "src\services\JSE.Pagamento.API\JSE.Pagamentos.API.csproj", "{6CBCEEF0-45E1-4050-9745-556ED2C4BDC9}"
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Pedidos.API", "src\services\JSE.Pedido.API\JSE.Pedidos.API.csproj", "{FCDB1D73-2DEA-41F9-87B7-67112E8B73C0}"
3737
EndProject
@@ -61,7 +61,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Pedidos.Infra", "src\se
6161
EndProject
6262
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Clientes.API", "src\services\JSE.Clientes.API\JSE.Clientes.API.csproj", "{AC75EECB-1BC5-4653-AB42-E8148D5B05D9}"
6363
EndProject
64-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSE.Pagamentos.NerdsPag", "src\services\JSE.Pagamentos.NerdsPag\JSE.Pagamentos.NerdsPag.csproj", "{3D83A7B3-B140-43CF-885C-660C043B498A}"
64+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JSE.Pagamentos.NerdsPag", "src\services\JSE.Pagamentos.NerdsPag\JSE.Pagamentos.NerdsPag.csproj", "{3D83A7B3-B140-43CF-885C-660C043B498A}"
6565
EndProject
6666
Global
6767
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace JSE.Core.Messages.Integration
2+
{
3+
public class PedidoBaixadoEstoqueIntegrationEvent : IntegrationEvent
4+
{
5+
public Guid ClienteId { get; private set; }
6+
public Guid PedidoId { get; private set; }
7+
8+
public PedidoBaixadoEstoqueIntegrationEvent(Guid clienteId, Guid pedidoId)
9+
{
10+
ClienteId = clienteId;
11+
PedidoId = pedidoId;
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace JSE.Core.Messages.Integration
2+
{
3+
public class PedidoCanceladoIntegrationEvent : IntegrationEvent
4+
{
5+
public Guid ClienteId { get; private set; }
6+
public Guid PedidoId { get; private set; }
7+
8+
public PedidoCanceladoIntegrationEvent(Guid clienteId, Guid pedidoId)
9+
{
10+
ClienteId = clienteId;
11+
PedidoId = pedidoId;
12+
}
13+
}
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace JSE.Core.Messages.Integration
2+
{
3+
public class PedidoIniciadoIntegrationEvent : IntegrationEvent
4+
{
5+
public Guid ClienteId { get; set; }
6+
public Guid PedidoId { get; set; }
7+
public int TipoPagamento { get; set; }
8+
public decimal Valor { get; set; }
9+
10+
public string NomeCartao { get; set; }
11+
public string NumeroCartao { get; set; }
12+
public string MesAnoVencimento { get; set; }
13+
public string CVV { get; set; }
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace JSE.Core.Messages.Integration
2+
{
3+
public class PedidoPagoIntegrationEvent : IntegrationEvent
4+
{
5+
public Guid ClienteId { get; private set; }
6+
public Guid PedidoId { get; private set; }
7+
8+
public PedidoPagoIntegrationEvent(Guid clienteId, Guid pedidoId)
9+
{
10+
ClienteId = clienteId;
11+
PedidoId = pedidoId;
12+
}
13+
}
14+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using JSE.Pagamentos.API.Data;
2+
using JSE.Pagamentos.Facade;
3+
using JSE.WebAPI.Core.IdentityConfiguration;
4+
using Microsoft.EntityFrameworkCore;
5+
6+
namespace JSE.Pagamentos.API.Configuration
7+
{
8+
public static class ApiConfig
9+
{
10+
public static void AddApiConfiguration(this IServiceCollection services, IConfiguration configuration)
11+
{
12+
services.AddDbContext<PagamentosContext>(options =>
13+
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));
14+
15+
services.AddControllers();
16+
17+
services.Configure<PagamentoConfig>(configuration.GetSection("PagamentoConfig"));
18+
19+
services.AddCors(options =>
20+
{
21+
options.AddPolicy("Total",
22+
builder =>
23+
builder
24+
.AllowAnyOrigin()
25+
.AllowAnyMethod()
26+
.AllowAnyHeader());
27+
});
28+
}
29+
30+
public static void UseApiConfiguration(this IApplicationBuilder app, IWebHostEnvironment env)
31+
{
32+
if (env.IsDevelopment())
33+
{
34+
app.UseDeveloperExceptionPage();
35+
}
36+
37+
app.UseHttpsRedirection();
38+
39+
app.UseRouting();
40+
41+
app.UseCors("Total");
42+
43+
app.UseAuthConfiguration();
44+
45+
app.UseEndpoints(endpoints =>
46+
{
47+
endpoints.MapControllers();
48+
});
49+
}
50+
}
51+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using JSE.Pagamentos.API.Data;
2+
using JSE.Pagamentos.API.Data.Repository;
3+
using JSE.Pagamentos.API.Models;
4+
using JSE.Pagamentos.API.Services;
5+
using JSE.Pagamentos.CardAntiCorruption;
6+
using JSE.Pagamentos.Facade;
7+
using JSE.WebAPI.Core.User;
8+
9+
namespace JSE.Pagamentos.API.Configuration
10+
{
11+
public static class DependencyInjectionConfig
12+
{
13+
public static void RegisterServices(this IServiceCollection services)
14+
{
15+
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
16+
services.AddScoped<IAspNetUser, AspNetUser>();
17+
18+
services.AddScoped<IPagamentoService, PagamentoService>();
19+
services.AddScoped<IPagamentoFacade, PagamentoCartaoCreditoFacade>();
20+
21+
services.AddScoped<IPagamentoRepository, PagamentoRepository>();
22+
services.AddScoped<PagamentosContext>();
23+
}
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using JSE.Core.Utils;
2+
using JSE.MessageBus;
3+
using JSE.Pagamentos.API.Services;
4+
5+
namespace JSE.Pagamentos.API.Configuration
6+
{
7+
public static class MessageBusConfig
8+
{
9+
public static void AddMessageBusConfiguration(this IServiceCollection services,
10+
IConfiguration configuration)
11+
{
12+
services.AddMessageBus(configuration.GetMessageQueueConnection("MessageBus"))
13+
.AddHostedService<PagamentoIntegrationHandler>();
14+
}
15+
}
16+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Microsoft.OpenApi.Models;
2+
3+
namespace JSE.Pagamentos.API.Configuration
4+
{
5+
public static class SwaggerConfig
6+
{
7+
public static void AddSwaggerConfiguration(this IServiceCollection services)
8+
{
9+
services.AddSwaggerGen(c =>
10+
{
11+
c.SwaggerDoc("v1", new OpenApiInfo()
12+
{
13+
Title = "JF Store Pagamentos API",
14+
Description = "Esta API faz parte do projeto ASP.NET Core Enterprise Applications.",
15+
Contact = new OpenApiContact() { Name = "Jeferson Almeida", Email = "jefferson_qi3@hotmail.com" },
16+
License = new OpenApiLicense() { Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT") }
17+
});
18+
19+
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
20+
{
21+
Description = "Insira o token JWT desta maneira: Bearer {seu token}",
22+
Name = "Authorization",
23+
Scheme = "Bearer",
24+
BearerFormat = "JWT",
25+
In = ParameterLocation.Header,
26+
Type = SecuritySchemeType.ApiKey
27+
});
28+
29+
c.AddSecurityRequirement(new OpenApiSecurityRequirement
30+
{
31+
{
32+
new OpenApiSecurityScheme
33+
{
34+
Reference = new OpenApiReference
35+
{
36+
Type = ReferenceType.SecurityScheme,
37+
Id = "Bearer"
38+
}
39+
},
40+
new string[] {}
41+
}
42+
});
43+
44+
});
45+
}
46+
47+
public static void UseSwaggerConfiguration(this IApplicationBuilder app)
48+
{
49+
app.UseSwagger();
50+
app.UseSwaggerUI(c =>
51+
{
52+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
53+
});
54+
}
55+
}
56+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using JSE.WebAPI.Core.Controllers;
2+
3+
namespace JSE.Pagamentos.API.Controllers
4+
{
5+
public class PagamentoController : MainController
6+
{
7+
8+
}
9+
}

0 commit comments

Comments
 (0)