Skip to content

Commit

Permalink
feat: update with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeHB69 committed Sep 12, 2024
2 parents f5835d9 + f999298 commit 3cdc1bd
Show file tree
Hide file tree
Showing 48 changed files with 801 additions and 116 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
steps:
- uses: deepakputhraya/action-branch-name@master
with:
regex: '([a-z])+\/([a-z_-])+\/([a-z_-])+'
regex: '([a-z])+\/([\dA-Za-z_-])+\/([\dA-Za-z_-])+\/([\dA-Za-z_-])+'
allowed_prefixes: 'feature,stable,fix,chore,docs,feat,build,ci,test,refactor,perf'
ignore: main,stage,develop
min_length: 4
max_length: 120
max_length: 150
39 changes: 27 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,35 @@
</PropertyGroup>
<ItemGroup>
<!-- Analyzers -->
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0"></PackageVersion>
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
</PackageVersion>
<!-- ASP.NET -->
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8"></PackageVersion>
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.3"></PackageVersion>
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8">
</PackageVersion>
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.3">
</PackageVersion>
<!-- Db Connection -->
<PackageVersion Include="Dapper" Version="2.1.35"></PackageVersion>
<PackageVersion Include="Npgsql" Version="8.0.3"></PackageVersion>
<PackageVersion Include="Dapper" Version="2.1.35">
</PackageVersion>
<PackageVersion Include="Npgsql" Version="8.0.3">
</PackageVersion>
<!-- Json Version -->
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3">
</PackageVersion>
<!-- Testing -->
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8"></PackageVersion>
<PackageVersion Include="Microsoft.Net.Test.Sdk" Version="17.11.1"></PackageVersion>
<PackageVersion Include="xunit" Version="2.9.0"></PackageVersion>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0-pre.30"></PackageVersion>
<PackageVersion Include="Moq" Version="4.20.71"></PackageVersion>
<PackageVersion Include="coverlet.msbuild" Version="6.0.2"></PackageVersion>
<PackageVersion Include="ReportGenerator" Version="5.3.9"></PackageVersion>
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8">
</PackageVersion>
<PackageVersion Include="Microsoft.Net.Test.Sdk" Version="17.11.1">
</PackageVersion>
<PackageVersion Include="xunit" Version="2.9.0">
</PackageVersion>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0-pre.30">
</PackageVersion>
<PackageVersion Include="Moq" Version="4.20.71">
</PackageVersion>
<PackageVersion Include="coverlet.msbuild" Version="6.0.2">
</PackageVersion>
<PackageVersion Include="ReportGenerator" Version="5.3.9">
</PackageVersion>
</ItemGroup>
</Project>
11 changes: 6 additions & 5 deletions documentation/branch-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Our branch naming strategy follows a specific format and uses prefixes to
indicate the purpose of the branch. The naming convention is structured as
follows:

- **Format**: `prefix/name/description`
- **prefix**: Indicates the type of work being done.
- **name**: Provides the last name of the developer in charge of the ticket.
- **description**: A brief description of the branch's purpose.
- Format: `prefix/taskId/username/taskName`
- `prefix`: Indicates the type of work (e.g., feature, fix, chore).
- `taskId`: The task ID or ticket number associated with the branch.
- `username`: The developer's username or last name.
- `taskName`: The task or feature name.

### Allowed Prefixes

Expand Down Expand Up @@ -54,7 +55,7 @@ to follow the naming rules:
Branch names must adhere to the following length constraints:

- **Minimum Length**: 4 characters
- **Maximum Length**: 120 characters
- **Maximum Length**: 150 characters

By following this branch naming strategy, we ensure clarity and consistency in
our workflow, making it easier to understand the purpose and context of each
Expand Down
7 changes: 4 additions & 3 deletions documentation/git-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ overview of our Git Flow:

## Branch Strategy

- Format: `prefix/name/description`
- Format: `prefix/taskId/username/taskName`
- `prefix`: Indicates the type of work (e.g., feature, fix, chore).
- `name`: The last name of the developer in charge of the ticket.
- `description`: Brief description of the branch's purpose.
- `taskId`: The task ID or ticket number associated with the branch.
- `username`: The developer's username or last name.
- `taskName`: The task or feature name.
- Allowed prefixes include: feature, stable, fix, chore, docs, feat, build, ci,
test, refactor, perf.

Expand Down
Binary file modified documentation/git-workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
namespace DistributionCenter.Application.Configurations;

using DistributionCenter.Application.Constants;
using DistributionCenter.Application.Contexts.Concretes;
using DistributionCenter.Application.Contexts.Interfaces;
using DistributionCenter.Application.Repositories.Concretes;
using DistributionCenter.Application.Repositories.Interfaces;
using DistributionCenter.Application.Tables.Connections.Concretes;
using DistributionCenter.Application.Tables.Connections.Interfaces;
using DistributionCenter.Application.Tables.Core.Concretes;
using DistributionCenter.Domain.Entities.Concretes;
using Microsoft.Extensions.DependencyInjection;
using System.Data;
using Constants;
using Contexts.Concretes;
using Contexts.Interfaces;
using Domain.Entities.Concretes;
using Repositories.Concretes;
using Repositories.Interfaces;
using Tables.Connections.Dapper.Concretes;
using Tables.Connections.Dapper.Interfaces;
using Tables.Connections.File.Concretes;
using Tables.Connections.File.Interfaces;
using Tables.Core.Concretes;

public static class ApplicationBuilderConfiguration
{
Expand All @@ -26,14 +28,21 @@ private static IServiceCollection ConfigurePersistence(
IConfiguration configuration
)
{
_ = services.AddScoped<IDbConnectionFactory>(_ => new NpgqlConnectionFactory(
_ = services.AddScoped<IDbConnectionFactory<IDbConnection> >(_ => new NpgqlConnectionFactory(
configuration[DbConstants.DefaultConnectionStringPath]!
));

_ = services.AddScoped<IFileConnectionFactory<Transport> >(_ => new JsonConnectionFactory<Transport>(
DbConstants.TransportSchema));

_ = services.AddScoped<IContext>(_ => new Context(
new Dictionary<Type, object>()
new Dictionary<Type, object>
{
{ typeof(Client), new ClientTable(_.GetRequiredService<IDbConnectionFactory>()) },
{ typeof(Product), new ProductTable(_.GetRequiredService<IDbConnectionFactory>()) },
{ typeof(Product), new ProductTable(_.GetRequiredService<IDbConnectionFactory<IDbConnection>>()) },
{ typeof(Client), new ClientTable(_.GetRequiredService<IDbConnectionFactory<
IDbConnection>>()) },
{typeof(Transport), new TransportTable(_.GetRequiredService<IFileConnectionFactory<
Transport>>())},
}
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ namespace DistributionCenter.Application.Constants;
public static class DbConstants
{
public const string DefaultConnectionStringPath = "Database:ConnectionString:DefaultConnection";
public const string TransportSchema = "transport";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper"></PackageReference>
<PackageReference Include="Newtonsoft.Json"></PackageReference>
<PackageReference Include="Npgsql"></PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace DistributionCenter.Application.Tables.Components.Information.Bases;

using DistributionCenter.Application.Tables.Components.Information.Interfaces;
using Interfaces;

public abstract class BaseEntityTableInformation : ITableInformation
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
namespace DistributionCenter.Application.Tables.Components.Information.Concretes;

using DistributionCenter.Application.Tables.Components.Information.Bases;
using Bases;

public class ClientTableInformation : BaseEntityTableInformation
{
public ClientTableInformation()
: base() { }

protected override string ObtainGetByIdFields()
{
return "name, last_name AS LastName, email";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace DistributionCenter.Application.Tables.Components.Information.Concretes;

using Bases;

public class TransportTableInformation : BaseEntityTableInformation
{
protected override string ObtainGetByIdFields()
{
return "name, capacity, availableUnits";
}

protected override string ObtainTableName()
{
return "transport";
}

protected override string ObtainCreateFields()
{
return "name, capacity, availableUnits";
}

protected override string ObtainCreateValues()
{
return "@Name, @Capacity, @AvailableUnits";
}

protected override string ObtainUpdateFields()
{
return "name = @Name, capacity = @Capacity, availableUnits = @AvailableUnits";
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Bases;

using DistributionCenter.Application.Tables.Components.QueryCommands.Interfaces;
using Interfaces;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Bases;

using DistributionCenter.Application.Tables.Components.QueryCommands.Interfaces;
using Interfaces;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Bases;

using System.Data;
using Connections.Dapper.Interfaces;
using DistributionCenter.Application.Tables.Components.QueryCommands.Bases;
using DistributionCenter.Application.Tables.Connections.Interfaces;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public abstract class BaseDapperCommand<T>(IDbConnectionFactory dbConnectionFactory, T entity, string tableName)
public abstract class BaseDapperCommand<T>(IDbConnectionFactory<IDbConnection> dbConnectionFactory, T entity, string tableName)
: BaseCommand<T>(entity)
where T : IEntity
{
protected IDbConnectionFactory DbConnectionFactory { get; } = dbConnectionFactory;
protected IDbConnectionFactory<IDbConnection> DbConnectionFactory { get; } = dbConnectionFactory;
protected string TableName { get; } = tableName;

public override async Task<Result> ExecuteAsync()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Bases;

using System.Data;
using Connections.Dapper.Interfaces;
using DistributionCenter.Application.Tables.Components.QueryCommands.Bases;
using DistributionCenter.Application.Tables.Connections.Interfaces;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public abstract class BaseDapperQuery<T>(IDbConnectionFactory dbConnectionFactory, string tableName) : BaseQuery<T>
public abstract class BaseDapperQuery<T>(IDbConnectionFactory<IDbConnection> dbConnectionFactory, string tableName) : BaseQuery<T>
where T : IEntity
{
protected IDbConnectionFactory DbConnectionFactory { get; } = dbConnectionFactory;
protected IDbConnectionFactory<IDbConnection> DbConnectionFactory { get; } = dbConnectionFactory;
protected string TableName { get; } = tableName;

public override async Task<Result<T>> ExecuteAsync()
Expand All @@ -19,9 +19,7 @@ public override async Task<Result<T>> ExecuteAsync()
Result<T> result = await Execute(connection);

if (result.IsSuccess)
{
return result.Value;
}

return result.Errors;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Concretes;

using System.Data;
using Bases;
using Commons.Errors;
using Commons.Results;
using Connections.Dapper.Interfaces;
using Domain.Entities.Interfaces;
using global::Dapper;
using DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Bases;
using DistributionCenter.Application.Tables.Connections.Interfaces;
using DistributionCenter.Commons.Errors;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public class CreateDapperCommand<T>(
IDbConnectionFactory dbConnectionFactory,
IDbConnectionFactory<IDbConnection> dbConnectionFactory,
T entity,
string tableName,
string fields,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Concretes;

using System.Data;
using Bases;
using Commons.Errors;
using Commons.Results;
using Connections.Dapper.Interfaces;
using Domain.Entities.Interfaces;
using global::Dapper;
using DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Bases;
using DistributionCenter.Application.Tables.Connections.Interfaces;
using DistributionCenter.Commons.Errors;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public class GetByIdDapperQuery<T>(IDbConnectionFactory dbConnectionFactory, string tableName, Guid id, string fields)
public class GetByIdDapperQuery<T>(IDbConnectionFactory<IDbConnection> dbConnectionFactory, string tableName, Guid id, string fields)
: BaseDapperQuery<T>(dbConnectionFactory, tableName)
where T : IEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Concretes;

using System.Data;
using Bases;
using Commons.Errors;
using Commons.Results;
using Connections.Dapper.Interfaces;
using Domain.Entities.Interfaces;
using global::Dapper;
using DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.Dapper.Bases;
using DistributionCenter.Application.Tables.Connections.Interfaces;
using DistributionCenter.Commons.Errors;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public class UpdateDapperCommand<T>(IDbConnectionFactory dbConnectionFactory, T entity, string tableName, string fields)
public class UpdateDapperCommand<T>(IDbConnectionFactory<IDbConnection> dbConnectionFactory, T entity, string tableName, string fields)
: BaseDapperCommand<T>(dbConnectionFactory, entity, tableName)
where T : IEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.File.Bases;

using Connections.File.Interfaces;
using DistributionCenter.Application.Tables.Components.QueryCommands.Bases;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public abstract class BaseJsonCommand<T>(IFileConnectionFactory<T> fileConnectionFactory, T entity)
: BaseCommand<T>(entity)
where T : IEntity
{
public override async Task<Result> ExecuteAsync()
{
List<T> data = await fileConnectionFactory.LoadDataAsync();
Result result = await Execute(data);

return result;
}

protected abstract Task<Result> Execute(IEnumerable<T> data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace DistributionCenter.Application.Tables.Components.QueryCommands.Concretes.File.Bases;

using Connections.File.Interfaces;
using DistributionCenter.Application.Tables.Components.QueryCommands.Bases;
using DistributionCenter.Commons.Results;
using DistributionCenter.Domain.Entities.Interfaces;

public abstract class BaseJsonQuery<T>(IFileConnectionFactory<T> fileConnectionFactory) :
BaseQuery<T>
where T : IEntity
{
public override async Task<Result<T>> ExecuteAsync()
{
List<T> data = await fileConnectionFactory.LoadDataAsync();
Result<T> result = await Execute(data);

if (!result.IsSuccess)
return result.Errors;

return result.Value;
}

protected abstract Task<Result<T>> Execute(IEnumerable<T> data);
}
Loading

0 comments on commit 3cdc1bd

Please sign in to comment.