diff --git a/.gitignore b/.gitignore index 31c7257..b299ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .tasks/ .agile/ +**/bin/ +**/obj/ diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..58f10e1 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + AgileWebs + AgileWebs + git + http://192.168.68.156:3000/AgileWebs/pos-transactions-bff + http://192.168.68.156:3000/AgileWebs/pos-transactions-bff + false + + diff --git a/Pos.Transactions.Bff.slnx b/Pos.Transactions.Bff.slnx new file mode 100644 index 0000000..7b2afad --- /dev/null +++ b/Pos.Transactions.Bff.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Pos.Transactions.Bff.Application/Adapters/DefaultPosTransactionsServiceClient.cs b/src/Pos.Transactions.Bff.Application/Adapters/DefaultPosTransactionsServiceClient.cs new file mode 100644 index 0000000..5d05e57 --- /dev/null +++ b/src/Pos.Transactions.Bff.Application/Adapters/DefaultPosTransactionsServiceClient.cs @@ -0,0 +1,12 @@ +using Pos.Transactions.Bff.Contracts.Requests; +using Pos.Transactions.Bff.Contracts.Responses; + +namespace Pos.Transactions.Bff.Application.Adapters; + +public sealed class DefaultPosTransactionsServiceClient : IPosTransactionsServiceClient +{ + public Task FetchAsync(GetPosTransactionSummaryRequest request, CancellationToken cancellationToken) + { + return Task.FromResult(new GetPosTransactionSummaryResponse(request.ContextId, "Default service-backed response.")); + } +} diff --git a/src/Pos.Transactions.Bff.Application/Adapters/IPosTransactionsServiceClient.cs b/src/Pos.Transactions.Bff.Application/Adapters/IPosTransactionsServiceClient.cs new file mode 100644 index 0000000..0a31b6c --- /dev/null +++ b/src/Pos.Transactions.Bff.Application/Adapters/IPosTransactionsServiceClient.cs @@ -0,0 +1,9 @@ +using Pos.Transactions.Bff.Contracts.Requests; +using Pos.Transactions.Bff.Contracts.Responses; + +namespace Pos.Transactions.Bff.Application.Adapters; + +public interface IPosTransactionsServiceClient +{ + Task FetchAsync(GetPosTransactionSummaryRequest request, CancellationToken cancellationToken); +} diff --git a/src/Pos.Transactions.Bff.Application/Handlers/GetPosTransactionSummaryHandler.cs b/src/Pos.Transactions.Bff.Application/Handlers/GetPosTransactionSummaryHandler.cs new file mode 100644 index 0000000..aa99a1c --- /dev/null +++ b/src/Pos.Transactions.Bff.Application/Handlers/GetPosTransactionSummaryHandler.cs @@ -0,0 +1,13 @@ +using Pos.Transactions.Bff.Application.Adapters; +using Pos.Transactions.Bff.Contracts.Requests; +using Pos.Transactions.Bff.Contracts.Responses; + +namespace Pos.Transactions.Bff.Application.Handlers; + +public sealed class GetPosTransactionSummaryHandler(IPosTransactionsServiceClient serviceClient) : IGetPosTransactionSummaryHandler +{ + public Task HandleAsync(GetPosTransactionSummaryRequest request, CancellationToken cancellationToken) + { + return serviceClient.FetchAsync(request, cancellationToken); + } +} diff --git a/src/Pos.Transactions.Bff.Application/Handlers/IGetPosTransactionSummaryHandler.cs b/src/Pos.Transactions.Bff.Application/Handlers/IGetPosTransactionSummaryHandler.cs new file mode 100644 index 0000000..836fada --- /dev/null +++ b/src/Pos.Transactions.Bff.Application/Handlers/IGetPosTransactionSummaryHandler.cs @@ -0,0 +1,9 @@ +using Pos.Transactions.Bff.Contracts.Requests; +using Pos.Transactions.Bff.Contracts.Responses; + +namespace Pos.Transactions.Bff.Application.Handlers; + +public interface IGetPosTransactionSummaryHandler +{ + Task HandleAsync(GetPosTransactionSummaryRequest request, CancellationToken cancellationToken); +} diff --git a/src/Pos.Transactions.Bff.Application/Pos.Transactions.Bff.Application.csproj b/src/Pos.Transactions.Bff.Application/Pos.Transactions.Bff.Application.csproj new file mode 100644 index 0000000..ae0c07d --- /dev/null +++ b/src/Pos.Transactions.Bff.Application/Pos.Transactions.Bff.Application.csproj @@ -0,0 +1,12 @@ + + + + net10.0 + enable + enable + + + + + + diff --git a/src/Pos.Transactions.Bff.Contracts/Pos.Transactions.Bff.Contracts.csproj b/src/Pos.Transactions.Bff.Contracts/Pos.Transactions.Bff.Contracts.csproj new file mode 100644 index 0000000..b760144 --- /dev/null +++ b/src/Pos.Transactions.Bff.Contracts/Pos.Transactions.Bff.Contracts.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + diff --git a/src/Pos.Transactions.Bff.Contracts/Requests/GetPosTransactionSummaryRequest.cs b/src/Pos.Transactions.Bff.Contracts/Requests/GetPosTransactionSummaryRequest.cs new file mode 100644 index 0000000..277a1b9 --- /dev/null +++ b/src/Pos.Transactions.Bff.Contracts/Requests/GetPosTransactionSummaryRequest.cs @@ -0,0 +1,3 @@ +namespace Pos.Transactions.Bff.Contracts.Requests; + +public sealed record GetPosTransactionSummaryRequest(string ContextId); diff --git a/src/Pos.Transactions.Bff.Contracts/Responses/GetPosTransactionSummaryResponse.cs b/src/Pos.Transactions.Bff.Contracts/Responses/GetPosTransactionSummaryResponse.cs new file mode 100644 index 0000000..9bbc25e --- /dev/null +++ b/src/Pos.Transactions.Bff.Contracts/Responses/GetPosTransactionSummaryResponse.cs @@ -0,0 +1,3 @@ +namespace Pos.Transactions.Bff.Contracts.Responses; + +public sealed record GetPosTransactionSummaryResponse(string ContextId, string Summary); diff --git a/src/Pos.Transactions.Bff.Rest/Pos.Transactions.Bff.Rest.csproj b/src/Pos.Transactions.Bff.Rest/Pos.Transactions.Bff.Rest.csproj new file mode 100644 index 0000000..d402546 --- /dev/null +++ b/src/Pos.Transactions.Bff.Rest/Pos.Transactions.Bff.Rest.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + enable + enable + + + + + + + diff --git a/src/Pos.Transactions.Bff.Rest/Program.cs b/src/Pos.Transactions.Bff.Rest/Program.cs new file mode 100644 index 0000000..d14e347 --- /dev/null +++ b/src/Pos.Transactions.Bff.Rest/Program.cs @@ -0,0 +1,17 @@ +using Pos.Transactions.Bff.Application.Adapters; +using Pos.Transactions.Bff.Application.Handlers; +using Pos.Transactions.Bff.Contracts.Requests; + +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +app.MapGet("/api/pos/transactions/summary", async (string contextId, IGetPosTransactionSummaryHandler handler, CancellationToken ct) => +{ + var request = new GetPosTransactionSummaryRequest(contextId); + return Results.Ok(await handler.HandleAsync(request, ct)); +}); + +app.Run(); diff --git a/src/Pos.Transactions.Bff.Rest/Properties/launchSettings.json b/src/Pos.Transactions.Bff.Rest/Properties/launchSettings.json new file mode 100644 index 0000000..c55f6a2 --- /dev/null +++ b/src/Pos.Transactions.Bff.Rest/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:0", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:0;http://localhost:0", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Pos.Transactions.Bff.Rest/appsettings.Development.json b/src/Pos.Transactions.Bff.Rest/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/Pos.Transactions.Bff.Rest/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Pos.Transactions.Bff.Rest/appsettings.json b/src/Pos.Transactions.Bff.Rest/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/Pos.Transactions.Bff.Rest/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}