netcore-blueprint 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BlueprintTemplate/Blueprint.API/{Controllers → AsyncControllers}/UserControllerAsync.cs +2 -2
- package/BlueprintTemplate/Blueprint.API/Blueprint.API.csproj +0 -1
- package/BlueprintTemplate/Blueprint.API/Program.cs +2 -1
- package/BlueprintTemplate/Blueprint.Core/Blueprint.Core.csproj +1 -0
- package/BlueprintTemplate/Blueprint.Core/Interfaces/SPI/IRepositoryFactory.cs +0 -1
- package/BlueprintTemplate/Blueprint.Core/Interfaces/SPI/IUserInfra.cs +2 -2
- package/BlueprintTemplate/Blueprint.Infra/Blueprint.Infra.csproj +0 -1
- package/BlueprintTemplate/Blueprint.Infra/Services/{MongoItemInfra.cs → Mongo/MongoItemInfra.cs} +3 -3
- package/BlueprintTemplate/Blueprint.Infra/Services/{MongoUserInfra.cs → Mongo/MongoUserInfra.cs} +2 -3
- package/BlueprintTemplate/Blueprint.Infra/Services/{MySQLItemInfra.cs → MySQL/MySQLItemInfra.cs} +1 -1
- package/BlueprintTemplate/Blueprint.Infra/Services/{MySQLUserInfra.cs → MySQL/MySQLUserInfra.cs} +2 -3
- package/BlueprintTemplate/Blueprint.Infra/Services/RepositoryFactory.cs +14 -10
- package/package.json +1 -1
- package/BlueprintTemplate/Blueprint.API/Controllers/WeatherForecastController.cs +0 -33
- /package/BlueprintTemplate/{Blueprint.Infra → Blueprint.Core}/Services/RabbitMqService.cs +0 -0
package/BlueprintTemplate/Blueprint.API/{Controllers → AsyncControllers}/UserControllerAsync.cs
RENAMED
|
@@ -3,11 +3,11 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
3
3
|
using System.Text.Json;
|
|
4
4
|
using Template.Core.Dtos.Requests;
|
|
5
5
|
|
|
6
|
-
namespace Blueprint.API.
|
|
6
|
+
namespace Blueprint.API.AsyncControllers
|
|
7
7
|
{
|
|
8
8
|
[Route("rest/v{version:apiVersion}/users-async")]
|
|
9
9
|
[ApiController]
|
|
10
|
-
public class UserControllerAsync: Controller
|
|
10
|
+
public class UserControllerAsync : Controller
|
|
11
11
|
{
|
|
12
12
|
private readonly IRabbitMqService _rabbitMqService;
|
|
13
13
|
private readonly ILogger<UserControllerAsync> _logger;
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
<PrivateAssets>all</PrivateAssets>
|
|
18
18
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
19
19
|
</PackageReference>
|
|
20
|
-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
|
21
20
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
|
22
21
|
</ItemGroup>
|
|
23
22
|
|
|
@@ -9,7 +9,6 @@ using Amazon.S3;
|
|
|
9
9
|
using Template.Core.Interfaces.API;
|
|
10
10
|
using Template.Core.Services;
|
|
11
11
|
using Template.Core.Interfaces.SPI;
|
|
12
|
-
using Template.Infra.Services;
|
|
13
12
|
using Blueprint.Core.Interfaces.API;
|
|
14
13
|
using Blueprint.Core.Interfaces.SPI;
|
|
15
14
|
using Blueprint.Infra.Services;
|
|
@@ -20,6 +19,8 @@ using System.Text;
|
|
|
20
19
|
using Blueprint.Core.Services;
|
|
21
20
|
using Amazon.SimpleSystemsManagement.Model;
|
|
22
21
|
using Amazon.SimpleSystemsManagement;
|
|
22
|
+
using Blueprint.Infra.Services.Mongo;
|
|
23
|
+
using Blueprint.Infra.Services.MySQL;
|
|
23
24
|
|
|
24
25
|
var builder = WebApplication.CreateBuilder(args);
|
|
25
26
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<ItemGroup>
|
|
11
11
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
|
12
12
|
<PackageReference Include="MongoDB.Bson" Version="3.1.0" />
|
|
13
|
+
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
|
13
14
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.1" />
|
|
14
15
|
</ItemGroup>
|
|
15
16
|
</Project>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
using Blueprint.Core.Entities;
|
|
2
|
-
using Blueprint.Core.Interfaces.
|
|
2
|
+
using Blueprint.Core.Interfaces.SPI;
|
|
3
3
|
|
|
4
4
|
namespace Template.Core.Interfaces.SPI
|
|
5
5
|
{
|
|
6
|
-
public interface IUserInfra:
|
|
6
|
+
public interface IUserInfra: IItemInfra<User>
|
|
7
7
|
{
|
|
8
8
|
public Task<User> GetUserByEmail(string email);
|
|
9
9
|
}
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
|
17
17
|
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
|
|
18
18
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
|
|
19
|
-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
|
|
20
19
|
</ItemGroup>
|
|
21
20
|
|
|
22
21
|
<ItemGroup>
|
package/BlueprintTemplate/Blueprint.Infra/Services/{MongoItemInfra.cs → Mongo/MongoItemInfra.cs}
RENAMED
|
@@ -5,7 +5,7 @@ using Blueprint.Core.Models;
|
|
|
5
5
|
using MongoDB.Driver;
|
|
6
6
|
using System.Linq.Expressions;
|
|
7
7
|
|
|
8
|
-
namespace Blueprint.Infra.Services
|
|
8
|
+
namespace Blueprint.Infra.Services.Mongo
|
|
9
9
|
{
|
|
10
10
|
public class MongoItemInfra<T> : IItemInfra<T> where T : BaseEntity
|
|
11
11
|
{
|
|
@@ -13,7 +13,7 @@ namespace Blueprint.Infra.Services
|
|
|
13
13
|
public readonly ILogger<MongoItemInfra<T>> _logger;
|
|
14
14
|
|
|
15
15
|
public MongoItemInfra(
|
|
16
|
-
IMongoDatabase database,
|
|
16
|
+
IMongoDatabase database,
|
|
17
17
|
ILogger<MongoItemInfra<T>> logger)
|
|
18
18
|
{
|
|
19
19
|
_dbSet = database.GetCollection<T>(typeof(T).Name.ToLower());
|
|
@@ -98,7 +98,7 @@ namespace Blueprint.Infra.Services
|
|
|
98
98
|
try
|
|
99
99
|
{
|
|
100
100
|
var id = typeof(T).GetProperty("Id")?.GetValue(item);
|
|
101
|
-
if (id == null)
|
|
101
|
+
if (id == null)
|
|
102
102
|
throw Errors.CannotFindTheItem;
|
|
103
103
|
|
|
104
104
|
await _dbSet.ReplaceOneAsync(Builders<T>.Filter.Eq("Id", id), item);
|
package/BlueprintTemplate/Blueprint.Infra/Services/{MongoUserInfra.cs → Mongo/MongoUserInfra.cs}
RENAMED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
using Blueprint.Core.Entities;
|
|
2
2
|
using Blueprint.Core.Errors;
|
|
3
3
|
using Blueprint.Infra.Database;
|
|
4
|
-
using Blueprint.Infra.Services;
|
|
5
4
|
using Microsoft.EntityFrameworkCore;
|
|
6
5
|
using MongoDB.Driver;
|
|
7
6
|
using Template.Core.Interfaces.SPI;
|
|
8
7
|
|
|
9
|
-
namespace
|
|
8
|
+
namespace Blueprint.Infra.Services.Mongo
|
|
10
9
|
{
|
|
11
10
|
public class MongoUserInfra : MongoItemInfra<User>, IUserInfra
|
|
12
11
|
{
|
|
13
|
-
public MongoUserInfra(IMongoDatabase dbContext, ILogger<MongoUserInfra> logger)
|
|
12
|
+
public MongoUserInfra(IMongoDatabase dbContext, ILogger<MongoUserInfra> logger)
|
|
14
13
|
: base(dbContext, logger)
|
|
15
14
|
{
|
|
16
15
|
}
|
package/BlueprintTemplate/Blueprint.Infra/Services/{MySQLUserInfra.cs → MySQL/MySQLUserInfra.cs}
RENAMED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
using Blueprint.Core.Entities;
|
|
2
2
|
using Blueprint.Core.Errors;
|
|
3
3
|
using Blueprint.Infra.Database;
|
|
4
|
-
using Blueprint.Infra.Services;
|
|
5
4
|
using Microsoft.EntityFrameworkCore;
|
|
6
5
|
using Template.Core.Interfaces.SPI;
|
|
7
6
|
|
|
8
|
-
namespace
|
|
7
|
+
namespace Blueprint.Infra.Services.MySQL
|
|
9
8
|
{
|
|
10
9
|
public class MySQLUserInfra : MySQLItemInfra<User>, IUserInfra
|
|
11
10
|
{
|
|
12
|
-
public MySQLUserInfra(MyDbContext dbContext, ILogger<MySQLUserInfra> logger)
|
|
11
|
+
public MySQLUserInfra(MyDbContext dbContext, ILogger<MySQLUserInfra> logger)
|
|
13
12
|
: base(dbContext, logger)
|
|
14
13
|
{
|
|
15
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
using Blueprint.Core.Entities;
|
|
2
2
|
using Blueprint.Core.Interfaces.SPI;
|
|
3
|
-
using
|
|
4
|
-
using
|
|
3
|
+
using Blueprint.Infra.Services.Mongo;
|
|
4
|
+
using Blueprint.Infra.Services.MySQL;
|
|
5
5
|
|
|
6
6
|
namespace Blueprint.Infra.Services
|
|
7
7
|
{
|
|
@@ -18,21 +18,25 @@ namespace Blueprint.Infra.Services
|
|
|
18
18
|
|
|
19
19
|
public IItemInfra<T> CreateItemRepository()
|
|
20
20
|
{
|
|
21
|
-
|
|
21
|
+
var dbType = _databaseType.ToLower();
|
|
22
|
+
var entityType = typeof(T);
|
|
23
|
+
|
|
24
|
+
Type implementationType = dbType switch
|
|
22
25
|
{
|
|
23
|
-
"mysql" =>
|
|
24
|
-
"mongodb" =>
|
|
26
|
+
"mysql" => GetMySqlImplementationType(entityType),
|
|
27
|
+
"mongodb" => typeof(MongoItemInfra<>).MakeGenericType(entityType),
|
|
25
28
|
_ => throw new ArgumentException("Invalid database type")
|
|
26
29
|
};
|
|
30
|
+
|
|
31
|
+
return (IItemInfra<T>)ActivatorUtilities.CreateInstance(_serviceProvider, implementationType);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
private Type GetMySqlImplementationType(Type entityType)
|
|
30
35
|
{
|
|
31
|
-
return
|
|
36
|
+
return entityType.Name switch
|
|
32
37
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_ => throw new ArgumentException("Invalid database type")
|
|
38
|
+
nameof(User) => typeof(MySQLUserInfra),
|
|
39
|
+
_ => typeof(MySQLItemInfra<>).MakeGenericType(entityType)
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
}
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
using Microsoft.AspNetCore.Mvc;
|
|
2
|
-
|
|
3
|
-
namespace Blueprint.API.Controllers
|
|
4
|
-
{
|
|
5
|
-
[ApiController]
|
|
6
|
-
[Route("[controller]")]
|
|
7
|
-
public class WeatherForecastController : ControllerBase
|
|
8
|
-
{
|
|
9
|
-
private static readonly string[] Summaries = new[]
|
|
10
|
-
{
|
|
11
|
-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
private readonly ILogger<WeatherForecastController> _logger;
|
|
15
|
-
|
|
16
|
-
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
|
17
|
-
{
|
|
18
|
-
_logger = logger;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
[HttpGet(Name = "GetWeatherForecast")]
|
|
22
|
-
public IEnumerable<WeatherForecast> Get()
|
|
23
|
-
{
|
|
24
|
-
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
|
25
|
-
{
|
|
26
|
-
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
|
27
|
-
TemperatureC = Random.Shared.Next(-20, 55),
|
|
28
|
-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
|
29
|
-
})
|
|
30
|
-
.ToArray();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
File without changes
|