Skip to content

Commit

Permalink
Release v0.8.0
Browse files Browse the repository at this point in the history
* Adds Caching
* Adds Caching Project
* Adds ExpirationTime to Cache Configuration
* Adds Caching Interfaces
* Adds Cache infra on Dockerfile
* Adds FinancialHub.Core.Infra.IntegrationTests project
* Adds FinancialHubInfraFixture and FinancialHubInfraSetup
* Adds FinancialHubBuilderSetup and FinancialHubSetup
* Adds appsettings and appsettings.Testing
* Changes Models private set to init
* Changes Application Mappers, Services e Validators concrete classes as internal
* Changes Infra Data and Caching concrete classes as internal
  • Loading branch information
Chingling152 committed Jun 10, 2024
1 parent f641f0b commit b1c501c
Show file tree
Hide file tree
Showing 108 changed files with 1,799 additions and 248 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
working-directory: ${{ inputs.dir }}

services:
redis-cache:
image: redis:latest
ports:
- "6379:6379"
sql-database:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/matrix_test_result.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
project-dir: ${{ inputs.dir }}/${{ matrix.project }}

services:
redis-cache:
image: redis:latest
ports:
- "6379:6379"
sql-database:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_result.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
working-directory: ${{ inputs.dir }}

services:
redis-cache:
image: redis:latest
ports:
- "6379:6379"
sql-database:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@
<ProjectReference Include="..\FinancialHub.Core.Domain\FinancialHub.Core.Domain.csproj" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>FinancialHub.Core.Application.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace FinancialHub.Core.Application.Mappers
{
public class AccountMapper : Profile
internal class AccountMapper : Profile
{
public AccountMapper()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace FinancialHub.Core.Application.Mappers
{
public class BalanceMapper : Profile
internal class BalanceMapper : Profile
{
public BalanceMapper()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace FinancialHub.Core.Application.Mappers
{
public class CategoryMapper : Profile
internal class CategoryMapper : Profile
{
public CategoryMapper()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace FinancialHub.Core.Application.Mappers
{
public class TransactionMapper : Profile
internal class TransactionMapper : Profile
{
public TransactionMapper()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace FinancialHub.Core.Application.Services
{
public class AccountsService : IAccountsService
internal class AccountsService : IAccountsService
{
private readonly IAccountsProvider provider;
private readonly IAccountsValidator accountValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace FinancialHub.Core.Application.Services
{
public class BalancesService : IBalancesService
internal class BalancesService : IBalancesService
{
private readonly IBalancesProvider balancesProvider;
private readonly IBalancesValidator balancesValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace FinancialHub.Core.Application.Services
{
public class CategoriesService : ICategoriesService
internal class CategoriesService : ICategoriesService
{
private readonly ICategoriesProvider provider;
private readonly ICategoriesValidator validator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace FinancialHub.Core.Application.Services
{
[Obsolete("This Service will be removed and the logic will be moved to Balance and Transaction models")]
public class TransactionBalanceService : ITransactionBalanceService
internal class TransactionBalanceService : ITransactionBalanceService
{
private readonly ITransactionsService transactionsService;
private readonly IBalancesService balancesService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FinancialHub.Core.Application.Services
{
public class TransactionsService : ITransactionsService
internal class TransactionsService : ITransactionsService
{
private readonly ITransactionsProvider transactionsProvider;
private readonly ITransactionsValidator transactionsValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace FinancialHub.Core.Application.Validators.Accounts
{
public class AccountsValidator : IAccountsValidator
internal class AccountsValidator : IAccountsValidator
{
private readonly IAccountsProvider accountsProvider;
private readonly IValidator<CreateAccountDto> createValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Accounts
{
public class CreateAccountValidator : AbstractValidator<CreateAccountDto>
internal class CreateAccountValidator : AbstractValidator<CreateAccountDto>
{
public CreateAccountValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Accounts
{
public class UpdateAccountValidator : AbstractValidator<UpdateAccountDto>
internal class UpdateAccountValidator : AbstractValidator<UpdateAccountDto>
{
public UpdateAccountValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FinancialHub.Common.Results.Errors;
using FinancialHub.Core.Application.Extensions;
using FinancialHub.Core.Application.Extensions;
using FinancialHub.Core.Domain.DTOS.Balances;
using FinancialHub.Core.Domain.Interfaces.Resources;
using FinancialHub.Core.Domain.Interfaces.Validators;
Expand All @@ -8,7 +7,7 @@

namespace FinancialHub.Core.Application.Validators.Balances
{
public class BalancesValidator : IBalancesValidator
internal class BalancesValidator : IBalancesValidator
{
private readonly IBalancesProvider balancesProvider;
private readonly IAccountsValidator accountValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Balances
{
public class CreateBalanceValidator : AbstractValidator<CreateBalanceDto>
internal class CreateBalanceValidator : AbstractValidator<CreateBalanceDto>
{
public CreateBalanceValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Balances
{
public class UpdateBalanceValidator : AbstractValidator<UpdateBalanceDto>
internal class UpdateBalanceValidator : AbstractValidator<UpdateBalanceDto>
{
public UpdateBalanceValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace FinancialHub.Core.Application.Validators.Categories
{
public class CategoriesValidator : ICategoriesValidator
internal class CategoriesValidator : ICategoriesValidator
{
private const string MESSAGE_LABEL = "Category";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Categories
{
public class CreateCategoryValidator : AbstractValidator<CreateCategoryDto>
internal class CreateCategoryValidator : AbstractValidator<CreateCategoryDto>
{
public CreateCategoryValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Categories
{
public class UpdateCategoryValidator : AbstractValidator<UpdateCategoryDto>
internal class UpdateCategoryValidator : AbstractValidator<UpdateCategoryDto>
{
public UpdateCategoryValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Transactions
{
public class CreateTransactionValidator : AbstractValidator<CreateTransactionDto>
internal class CreateTransactionValidator : AbstractValidator<CreateTransactionDto>
{
public CreateTransactionValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace FinancialHub.Core.Application.Validators.Transactions
{
public class TransactionsValidator : ITransactionsValidator
internal class TransactionsValidator : ITransactionsValidator
{
private const string MESSAGE_LABEL = "Transaction";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinancialHub.Core.Application.Validators.Transactions
{
public class UpdateTransactionValidator : AbstractValidator<UpdateTransactionDto>
internal class UpdateTransactionValidator : AbstractValidator<UpdateTransactionDto>
{
public UpdateTransactionValidator(IValidationErrorMessageProvider errorMessageProvider)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FinancialHub.Core.Domain.Models;

namespace FinancialHub.Core.Domain.Interfaces.Caching
{
public interface IAccountsCache
{
Task AddAsync(AccountModel account);
Task<AccountModel?> GetAsync(Guid id);
Task RemoveAsync(Guid id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using FinancialHub.Core.Domain.Models;

namespace FinancialHub.Core.Domain.Interfaces.Caching
{
public interface IBalancesCache
{
Task AddAsync(BalanceModel balance);
Task AddAsync(IEnumerable<BalanceModel> balances);
Task<ICollection<BalanceModel>> GetByAccountAsync(Guid accountId);
Task<BalanceModel?> GetAsync(Guid id);
Task RemoveAsync(Guid id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FinancialHub.Core.Domain.Models;

namespace FinancialHub.Core.Domain.Interfaces.Caching
{
public interface ICategoriesCache
{
Task AddAsync(CategoryModel category);
Task<CategoryModel?> GetAsync(Guid id);
Task RemoveAsync(Guid id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using FinancialHub.Core.Domain.Filters;
using FinancialHub.Core.Domain.Models;

namespace FinancialHub.Core.Domain.Interfaces.Caching
{
[Obsolete("No use for it. Filters are too complex to use cache")]

Check warning on line 6 in src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/ITransactionsCache.cs

View workflow job for this annotation

GitHub Actions / Code Analysis / Code coverage

Do not forget to remove this deprecated code someday.

Check warning on line 6 in src/api/core/FinancialHub.Core.Domain/Interfaces/Caching/ITransactionsCache.cs

View workflow job for this annotation

GitHub Actions / Code Analysis / Code coverage

Do not forget to remove this deprecated code someday.
public interface ITransactionsCache
{
Task AddAsync(TransactionModel transaction);
Task<ICollection<TransactionModel>> GetAsync(params Guid[] balances);
Task<ICollection<TransactionModel>> GetAsync(TransactionFilter filter);
Task RemoveAsync(Guid id);
}
}
6 changes: 3 additions & 3 deletions src/api/core/FinancialHub.Core.Domain/Models/AccountModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public class AccountModel : BaseModel
{
public string Name { get; private set; }
public string Description { get; private set; }
public bool IsActive { get; private set; }
public string Name { get; init; }
public string Description { get; init; }
public bool IsActive { get; init; }
}
}
12 changes: 6 additions & 6 deletions src/api/core/FinancialHub.Core.Domain/Models/BalanceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
public class BalanceModel : BaseModel
{
public string Name { get; set; }
public string Currency { get; set; }
public decimal Amount { get; set; }
public Guid AccountId { get; set; }
public AccountModel Account { get; set; }
public bool IsActive { get; set; }
public string Name { get; init; }
public string Currency { get; init; }
public decimal Amount { get; init; }
public Guid AccountId { get; init; }
public AccountModel Account { get; init; }
public bool IsActive { get; init; }
}
}
6 changes: 3 additions & 3 deletions src/api/core/FinancialHub.Core.Domain/Models/CategoryModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public class CategoryModel : BaseModel
{
public string Name { get; private set; }
public string Description { get; private set; }
public bool IsActive { get; private set; }
public string Name { get; init; }
public string Description { get; init; }
public bool IsActive { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace FinancialHub.Core.Infra.Caching.Configurations
{
internal class CacheConfiguration
{
public const string Cache = "Cache";

public int ExpirationTime { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using FinancialHub.Core.Infra.Caching.Repositories;
using FinancialHub.Core.Infra.Caching.Configurations;

namespace FinancialHub.Core.Infra.Caching.Extensions.Configurations
{
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddCaching(this IServiceCollection services, IConfiguration configuration)
{
services
.AddCachingConfiguration(configuration)
.AddRedisCaching(configuration)
.AddCachingServices();

return services;
}

private static IServiceCollection AddRedisCaching(this IServiceCollection services, IConfiguration configuration)
{
services.AddStackExchangeRedisCache((options) =>
{
options.Configuration = configuration.GetConnectionString("cache");
});

return services;
}

private static IServiceCollection AddCachingServices(this IServiceCollection services)
{
services.AddScoped<IAccountsCache, AccountsCache>();
services.AddScoped<IBalancesCache, BalancesCache>();
services.AddScoped<ICategoriesCache, CategoriesCache>();
return services;
}

private static IServiceCollection AddCachingConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.AddOptions();
services.Configure<CacheConfiguration>(options =>
{
options.ExpirationTime = int.Parse(configuration["Cache:ExpirationTime"]);
});
return services;
}
}
}
Loading

0 comments on commit b1c501c

Please sign in to comment.