netcore-blueprint 0.0.2 → 0.0.3
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/Host.API/Extensions/ApplicationBuilderExtensions.cs +26 -0
- package/BlueprintTemplate/Host.API/Extensions/DatabaseExtensions.cs +37 -0
- package/BlueprintTemplate/Host.API/Extensions/ServiceCollectionExtensions.cs +54 -0
- package/BlueprintTemplate/Host.API/Extensions/ThirdPartyExtensions.cs +30 -0
- package/BlueprintTemplate/Host.API/Host.API.csproj +29 -0
- package/BlueprintTemplate/Host.API/Host.API.csproj.user +6 -0
- package/BlueprintTemplate/Host.API/Host.API.http +6 -0
- package/BlueprintTemplate/Host.API/Program.cs +25 -0
- package/BlueprintTemplate/Host.API/Properties/launchSettings.json +23 -0
- package/BlueprintTemplate/Host.API/appsettings.Development.json +8 -0
- package/BlueprintTemplate/Host.API/appsettings.json +15 -0
- package/BlueprintTemplate/ItemModule.API/Controllers/Public/ItemController.cs +65 -0
- package/BlueprintTemplate/ItemModule.API/ItemModule.API.csproj +26 -0
- package/BlueprintTemplate/ItemModule.API/Mappers/DtoItemMappingProfile.cs +26 -0
- package/BlueprintTemplate/ItemModule.Core/Dtos/Admin/ItemRequestDto.cs +8 -0
- package/BlueprintTemplate/ItemModule.Core/Dtos/Admin/ItemResponseDto.cs +8 -0
- package/BlueprintTemplate/ItemModule.Core/Entities/Item.cs +8 -0
- package/BlueprintTemplate/ItemModule.Core/Interfaces/API/IItemService.cs +9 -0
- package/BlueprintTemplate/ItemModule.Core/Interfaces/SPI/IItemInfra.cs +9 -0
- package/BlueprintTemplate/ItemModule.Core/ItemModule.Core.csproj +18 -0
- package/BlueprintTemplate/ItemModule.Core/Services/ItemService.cs +20 -0
- package/BlueprintTemplate/ItemModule.Infrastructure/Database/ItemConfiguration.cs +22 -0
- package/BlueprintTemplate/ItemModule.Infrastructure/Database/Seeder.cs +21 -0
- package/BlueprintTemplate/ItemModule.Infrastructure/ItemDependencyInjection.cs +27 -0
- package/BlueprintTemplate/ItemModule.Infrastructure/ItemModule.Infrastructure.csproj +14 -0
- package/BlueprintTemplate/ItemModule.Infrastructure/Services/MySQLItemInfra.cs +16 -0
- package/BlueprintTemplate/MyBlueprint.slnx +23 -0
- package/BlueprintTemplate/README.md +22 -0
- package/BlueprintTemplate/Shared.Core/Dtos/Requests/BaseRequestDto.cs +27 -0
- package/BlueprintTemplate/Shared.Core/Dtos/Responses/BaseResponseDto.cs +27 -0
- package/BlueprintTemplate/Shared.Core/Entities/BaseEntity.cs +15 -0
- package/BlueprintTemplate/Shared.Core/Enums/EntityStatus.cs +9 -0
- package/BlueprintTemplate/Shared.Core/Exceptions/Errors.cs +20 -0
- package/BlueprintTemplate/Shared.Core/Interfaces/API/IItemService.cs +14 -0
- package/BlueprintTemplate/Shared.Core/Interfaces/SPI/IItemInfra.cs +14 -0
- package/BlueprintTemplate/Shared.Core/Interfaces/SPI/IModuleSeeder.cs +9 -0
- package/BlueprintTemplate/Shared.Core/Interfaces/SPI/IRepositoryFactory.cs +7 -0
- package/BlueprintTemplate/Shared.Core/Models/Error.cs +69 -0
- package/BlueprintTemplate/Shared.Core/Models/ErrorDetail.cs +8 -0
- package/BlueprintTemplate/Shared.Core/Models/PagerData.cs +8 -0
- package/BlueprintTemplate/Shared.Core/Models/PagingParams.cs +8 -0
- package/BlueprintTemplate/Shared.Core/Services/ItemService.cs +53 -0
- package/BlueprintTemplate/Shared.Core/Shared.Core.csproj +13 -0
- package/BlueprintTemplate/Shared.Infrastructure/DbInitializer.cs +18 -0
- package/BlueprintTemplate/Shared.Infrastructure/Migrations/20260131121133_SeedInitialData.Designer.cs +123 -0
- package/BlueprintTemplate/Shared.Infrastructure/Migrations/20260131121133_SeedInitialData.cs +82 -0
- package/BlueprintTemplate/Shared.Infrastructure/Migrations/MyDbContextModelSnapshot.cs +120 -0
- package/BlueprintTemplate/Shared.Infrastructure/MyDbContext.cs +24 -0
- package/BlueprintTemplate/Shared.Infrastructure/Services/Mongo/MongoItemInfra.cs +117 -0
- package/BlueprintTemplate/Shared.Infrastructure/Services/MySQL/MySQLItemInfra.cs +132 -0
- package/BlueprintTemplate/Shared.Infrastructure/Services/RepositoryFactory.cs +36 -0
- package/BlueprintTemplate/Shared.Infrastructure/Shared.Infrastructure.csproj +28 -0
- package/BlueprintTemplate/Shared.Infrastructure/SharedDependencyInjection.cs +19 -0
- package/BlueprintTemplate/User.API/Controllers/Admin/UserController.cs +153 -0
- package/BlueprintTemplate/User.API/Mappers/DtoUserMappingProfile.cs +27 -0
- package/BlueprintTemplate/User.API/UserModule.API.csproj +26 -0
- package/BlueprintTemplate/User.Core/Dtos/Admin/UserRequestDto.cs +12 -0
- package/BlueprintTemplate/User.Core/Dtos/Admin/UserResponseDto.cs +12 -0
- package/BlueprintTemplate/User.Core/Entities/User.cs +13 -0
- package/BlueprintTemplate/User.Core/Enums/UserRole.cs +8 -0
- package/BlueprintTemplate/User.Core/Interfaces/API/IUserService.cs +9 -0
- package/BlueprintTemplate/User.Core/Interfaces/SPI/IUserInfra.cs +9 -0
- package/BlueprintTemplate/User.Core/Services/UserService.cs +20 -0
- package/BlueprintTemplate/User.Core/UserModule.Core.csproj +17 -0
- package/BlueprintTemplate/User.Infrastructure/Database/ItemConfiguration.cs +27 -0
- package/BlueprintTemplate/User.Infrastructure/Database/Seeder.cs +44 -0
- package/BlueprintTemplate/User.Infrastructure/Services/MySQLUserInfra.cs +16 -0
- package/BlueprintTemplate/User.Infrastructure/UserDependencyInjection.cs +22 -0
- package/BlueprintTemplate/User.Infrastructure/UserModule.Infrastructure.csproj +14 -0
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
using Shared.Core.Enums;
|
|
2
|
+
|
|
3
|
+
namespace Shared.Core.Dtos.Responses
|
|
4
|
+
{
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// BaseResponseDto
|
|
7
|
+
/// </summary>
|
|
8
|
+
public class BaseResponseDto
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// Id
|
|
12
|
+
/// </summary>
|
|
13
|
+
public Guid? Id { get; set; }
|
|
14
|
+
/// <summary>
|
|
15
|
+
/// Status
|
|
16
|
+
/// </summary>
|
|
17
|
+
public EntityStatus? Status { get; set; }
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Date
|
|
20
|
+
/// </summary>
|
|
21
|
+
public DateTime? Date { get; set; }
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Modified
|
|
24
|
+
/// </summary>
|
|
25
|
+
public DateTime? Modified { get; set; }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
using Microsoft.EntityFrameworkCore;
|
|
2
|
+
using Shared.Core.Enums;
|
|
3
|
+
using System.ComponentModel.DataAnnotations;
|
|
4
|
+
|
|
5
|
+
namespace Shared.Core.Entities
|
|
6
|
+
{
|
|
7
|
+
public abstract class BaseEntity
|
|
8
|
+
{
|
|
9
|
+
[Key]
|
|
10
|
+
public Guid Id { get; set; }
|
|
11
|
+
public EntityStatus Status { get; set; } = EntityStatus.Active;
|
|
12
|
+
public DateTime Date { get; set; } = DateTime.Now;
|
|
13
|
+
public DateTime Modified { get; set; } = DateTime.Now;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
using Shared.Core.Shared.Models;
|
|
2
|
+
using System.Net;
|
|
3
|
+
|
|
4
|
+
namespace Shared.Core.Exceptions
|
|
5
|
+
{
|
|
6
|
+
public static class Errors
|
|
7
|
+
{
|
|
8
|
+
public static readonly Error CannotQueryError = new Error("E-001", "Cannot do the query", HttpStatusCode.InternalServerError);
|
|
9
|
+
public static readonly Error CannotFindTheItem = new Error("E-002", "Cannot find the item", HttpStatusCode.NotFound);
|
|
10
|
+
|
|
11
|
+
//S3 Error
|
|
12
|
+
public static readonly Error HaveNoFile = new Error("E-S3-001", "Do not have file", HttpStatusCode.InternalServerError);
|
|
13
|
+
public static readonly Error CannotUploadFile = new Error("E-S3-002", "Cannot upload file to S3", HttpStatusCode.InternalServerError);
|
|
14
|
+
|
|
15
|
+
//Authen, Author Error
|
|
16
|
+
public static readonly Error CannotReadToken = new Error("E-AU-001", "Cannot read the token", HttpStatusCode.Unauthorized);
|
|
17
|
+
public static readonly Error EmptyToken = new Error("E-AU-002", "Token cannot be empty", HttpStatusCode.Unauthorized);
|
|
18
|
+
public static readonly Error InvalidToken = new Error("E-AU-002", "Invalid token", HttpStatusCode.Unauthorized);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
using Shared.Core.Shared.Models;
|
|
2
|
+
using System.Linq.Expressions;
|
|
3
|
+
|
|
4
|
+
namespace Shared.Core.Interfaces.API
|
|
5
|
+
{
|
|
6
|
+
public interface IItemService<T>
|
|
7
|
+
{
|
|
8
|
+
Task<PagerData<T>> GetItemsAsync(PagingParams pagingParams, params Expression<Func<T, object>>[] includes);
|
|
9
|
+
Task<T> GetItemByIdAsync(Guid id, params Expression<Func<T, object>>[] includes);
|
|
10
|
+
Task AddItemAsync(T item);
|
|
11
|
+
Task UpdateItemAsync(T item);
|
|
12
|
+
Task DeleteItemsAsync(List<Guid> ids);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
using Shared.Core.Shared.Models;
|
|
2
|
+
using System.Linq.Expressions;
|
|
3
|
+
|
|
4
|
+
namespace Shared.Core.Interfaces.SPI
|
|
5
|
+
{
|
|
6
|
+
public interface IItemInfra<T>
|
|
7
|
+
{
|
|
8
|
+
Task<PagerData<T>> GetItemsAsync(PagingParams pagingParams, params Expression<Func<T, object>>[] includes);
|
|
9
|
+
Task<T> GetItemByIdAsync(Guid id, params Expression<Func<T, object>>[] includes);
|
|
10
|
+
Task AddItemAsync(T item);
|
|
11
|
+
Task UpdateItemAsync(T item);
|
|
12
|
+
Task DeleteItemsAsync(List<Guid> ids);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
using System.Net;
|
|
2
|
+
|
|
3
|
+
namespace Shared.Core.Shared.Models
|
|
4
|
+
{
|
|
5
|
+
public class Error : Exception
|
|
6
|
+
{
|
|
7
|
+
public string Code { get; set; }
|
|
8
|
+
public string Description { get; set; }
|
|
9
|
+
public HttpStatusCode HttpStatusCode { get; set; }
|
|
10
|
+
public bool IsFinal { get; set; }
|
|
11
|
+
public ErrorDetail Detail { get; set; }
|
|
12
|
+
public Error()
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
public Error(string code, string description, HttpStatusCode httpStatusCode)
|
|
16
|
+
{
|
|
17
|
+
Code = code;
|
|
18
|
+
Description = description;
|
|
19
|
+
HttpStatusCode = httpStatusCode;
|
|
20
|
+
IsFinal = true;
|
|
21
|
+
}
|
|
22
|
+
public Error(string code, string description, HttpStatusCode httpStatusCode, bool isFinal)
|
|
23
|
+
{
|
|
24
|
+
Code = code;
|
|
25
|
+
Description = description;
|
|
26
|
+
HttpStatusCode = httpStatusCode;
|
|
27
|
+
IsFinal = isFinal;
|
|
28
|
+
}
|
|
29
|
+
public Error(string code, string description, ErrorDetail details, HttpStatusCode httpStatusCode, bool isFinal)
|
|
30
|
+
: this(code, description, httpStatusCode, isFinal)
|
|
31
|
+
{
|
|
32
|
+
Detail = details;
|
|
33
|
+
}
|
|
34
|
+
public void Throw()
|
|
35
|
+
{
|
|
36
|
+
throw this;
|
|
37
|
+
}
|
|
38
|
+
[Obsolete("Should be replaced by WithDescription method")]
|
|
39
|
+
public void Throw(string description)
|
|
40
|
+
{
|
|
41
|
+
throw new Error(Code, description, HttpStatusCode, IsFinal);
|
|
42
|
+
}
|
|
43
|
+
public Error WithDetails(ErrorDetail details)
|
|
44
|
+
{
|
|
45
|
+
Detail = details;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
public Error WithDescription(string description)
|
|
49
|
+
{
|
|
50
|
+
return new Error(Code, description, HttpStatusCode, IsFinal);
|
|
51
|
+
}
|
|
52
|
+
public Error WithFormatParams(object param0)
|
|
53
|
+
{
|
|
54
|
+
return new Error(Code, string.Format(Description, param0), HttpStatusCode, IsFinal);
|
|
55
|
+
}
|
|
56
|
+
public Error WithFormatParams(object param0, object param1)
|
|
57
|
+
{
|
|
58
|
+
return new Error(Code, string.Format(Description, param0, param1), HttpStatusCode, IsFinal);
|
|
59
|
+
}
|
|
60
|
+
public Error WithFormatParams(object param0, object param1, object param2)
|
|
61
|
+
{
|
|
62
|
+
return new Error(Code, string.Format(Description, param0, param1, param2), HttpStatusCode, IsFinal);
|
|
63
|
+
}
|
|
64
|
+
public Error WithFormatParams(object param0, object param1, object param2, object param3)
|
|
65
|
+
{
|
|
66
|
+
return new Error(Code, string.Format(Description, param0, param1, param2, param3), HttpStatusCode, IsFinal);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
using Microsoft.Extensions.Logging;
|
|
2
|
+
using Shared.Core.Entities;
|
|
3
|
+
using Shared.Core.Interfaces.API;
|
|
4
|
+
using Shared.Core.Interfaces.SPI;
|
|
5
|
+
using Shared.Core.Shared.Models;
|
|
6
|
+
using System.Linq.Expressions;
|
|
7
|
+
|
|
8
|
+
namespace Shared.Core.Services
|
|
9
|
+
{
|
|
10
|
+
public class ItemService<T> : IItemService<T> where T : BaseEntity
|
|
11
|
+
{
|
|
12
|
+
private readonly IItemInfra<T> _itemInfra;
|
|
13
|
+
private ILogger? _logger;
|
|
14
|
+
|
|
15
|
+
public ItemService(
|
|
16
|
+
ILogger logger,
|
|
17
|
+
IRepositoryFactory<T> repositoryFactory
|
|
18
|
+
)
|
|
19
|
+
{
|
|
20
|
+
_itemInfra = repositoryFactory.CreateItemRepository();
|
|
21
|
+
_logger = logger;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public Task AddItemAsync(T item)
|
|
25
|
+
{
|
|
26
|
+
return _itemInfra.AddItemAsync(item);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public Task DeleteItemsAsync(List<Guid> ids)
|
|
30
|
+
{
|
|
31
|
+
return _itemInfra.DeleteItemsAsync(ids);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public Task<T> GetItemByIdAsync(
|
|
35
|
+
Guid id,
|
|
36
|
+
params Expression<Func<T, object>>[] includes)
|
|
37
|
+
{
|
|
38
|
+
return _itemInfra.GetItemByIdAsync(id, includes);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public virtual Task<PagerData<T>> GetItemsAsync(
|
|
42
|
+
PagingParams pagingParams,
|
|
43
|
+
params Expression<Func<T, object>>[] includes)
|
|
44
|
+
{
|
|
45
|
+
return _itemInfra.GetItemsAsync(pagingParams, includes);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public Task UpdateItemAsync(T item)
|
|
49
|
+
{
|
|
50
|
+
return _itemInfra.UpdateItemAsync(item);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<TargetFramework>net10.0</TargetFramework>
|
|
5
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
6
|
+
<Nullable>enable</Nullable>
|
|
7
|
+
</PropertyGroup>
|
|
8
|
+
|
|
9
|
+
<ItemGroup>
|
|
10
|
+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
|
11
|
+
</ItemGroup>
|
|
12
|
+
|
|
13
|
+
</Project>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
using Microsoft.EntityFrameworkCore;
|
|
2
|
+
using Shared.Core.Interfaces.SPI;
|
|
3
|
+
|
|
4
|
+
namespace Shared.Infrastructure
|
|
5
|
+
{
|
|
6
|
+
public static class DbInitializer
|
|
7
|
+
{
|
|
8
|
+
public static void Seed(
|
|
9
|
+
ModelBuilder modelBuilder,
|
|
10
|
+
IEnumerable<IModuleSeeder> seeders)
|
|
11
|
+
{
|
|
12
|
+
foreach (var seeder in seeders)
|
|
13
|
+
{
|
|
14
|
+
seeder.Seed(modelBuilder);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// <auto-generated />
|
|
2
|
+
using System;
|
|
3
|
+
using Microsoft.EntityFrameworkCore;
|
|
4
|
+
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
5
|
+
using Microsoft.EntityFrameworkCore.Metadata;
|
|
6
|
+
using Microsoft.EntityFrameworkCore.Migrations;
|
|
7
|
+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
8
|
+
using Shared.Infrastructure;
|
|
9
|
+
|
|
10
|
+
#nullable disable
|
|
11
|
+
|
|
12
|
+
namespace Shared.Infrastructure.Migrations
|
|
13
|
+
{
|
|
14
|
+
[DbContext(typeof(MyDbContext))]
|
|
15
|
+
[Migration("20260131121133_SeedInitialData")]
|
|
16
|
+
partial class SeedInitialData
|
|
17
|
+
{
|
|
18
|
+
/// <inheritdoc />
|
|
19
|
+
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
20
|
+
{
|
|
21
|
+
#pragma warning disable 612, 618
|
|
22
|
+
modelBuilder
|
|
23
|
+
.HasAnnotation("ProductVersion", "9.0.0")
|
|
24
|
+
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
|
25
|
+
|
|
26
|
+
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
|
27
|
+
|
|
28
|
+
modelBuilder.Entity("ItemModule.Core.Entities.Item", b =>
|
|
29
|
+
{
|
|
30
|
+
b.Property<Guid>("Id")
|
|
31
|
+
.ValueGeneratedOnAdd()
|
|
32
|
+
.HasColumnType("char(36)");
|
|
33
|
+
|
|
34
|
+
b.Property<DateTime>("Date")
|
|
35
|
+
.HasColumnType("datetime(6)");
|
|
36
|
+
|
|
37
|
+
b.Property<DateTime>("Modified")
|
|
38
|
+
.HasColumnType("datetime(6)");
|
|
39
|
+
|
|
40
|
+
b.Property<int>("Status")
|
|
41
|
+
.HasColumnType("int");
|
|
42
|
+
|
|
43
|
+
b.HasKey("Id");
|
|
44
|
+
|
|
45
|
+
b.ToTable("Item");
|
|
46
|
+
|
|
47
|
+
b.HasData(
|
|
48
|
+
new
|
|
49
|
+
{
|
|
50
|
+
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
51
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 981, DateTimeKind.Local).AddTicks(3227),
|
|
52
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 981, DateTimeKind.Local).AddTicks(3237),
|
|
53
|
+
Status = 1
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
modelBuilder.Entity("UserModule.Core.Entities.User", b =>
|
|
58
|
+
{
|
|
59
|
+
b.Property<Guid>("Id")
|
|
60
|
+
.ValueGeneratedOnAdd()
|
|
61
|
+
.HasColumnType("char(36)");
|
|
62
|
+
|
|
63
|
+
b.Property<DateTime>("Date")
|
|
64
|
+
.HasColumnType("datetime(6)");
|
|
65
|
+
|
|
66
|
+
b.Property<string>("Email")
|
|
67
|
+
.HasColumnType("longtext");
|
|
68
|
+
|
|
69
|
+
b.Property<DateTime>("Modified")
|
|
70
|
+
.HasColumnType("datetime(6)");
|
|
71
|
+
|
|
72
|
+
b.Property<string>("Name")
|
|
73
|
+
.HasColumnType("longtext");
|
|
74
|
+
|
|
75
|
+
b.Property<string>("Picture")
|
|
76
|
+
.HasColumnType("longtext");
|
|
77
|
+
|
|
78
|
+
b.Property<int>("Role")
|
|
79
|
+
.HasColumnType("int");
|
|
80
|
+
|
|
81
|
+
b.Property<int>("Status")
|
|
82
|
+
.HasColumnType("int");
|
|
83
|
+
|
|
84
|
+
b.HasKey("Id");
|
|
85
|
+
|
|
86
|
+
b.ToTable("User");
|
|
87
|
+
|
|
88
|
+
b.HasData(
|
|
89
|
+
new
|
|
90
|
+
{
|
|
91
|
+
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
92
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(6970),
|
|
93
|
+
Email = "",
|
|
94
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(6987),
|
|
95
|
+
Name = "Test",
|
|
96
|
+
Role = 1,
|
|
97
|
+
Status = 1
|
|
98
|
+
},
|
|
99
|
+
new
|
|
100
|
+
{
|
|
101
|
+
Id = new Guid("22222222-2222-2222-2222-222222222222"),
|
|
102
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8351),
|
|
103
|
+
Email = "truongdxfx08031@funix.edu.vn",
|
|
104
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8352),
|
|
105
|
+
Name = "Truong Dang",
|
|
106
|
+
Role = 0,
|
|
107
|
+
Status = 1
|
|
108
|
+
},
|
|
109
|
+
new
|
|
110
|
+
{
|
|
111
|
+
Id = new Guid("33333333-3333-3333-3333-333333333333"),
|
|
112
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8358),
|
|
113
|
+
Email = "truonghusk17aws1@gmail.com",
|
|
114
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8358),
|
|
115
|
+
Name = "Thai Son",
|
|
116
|
+
Role = 0,
|
|
117
|
+
Status = 1
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
#pragma warning restore 612, 618
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using Microsoft.EntityFrameworkCore.Migrations;
|
|
3
|
+
|
|
4
|
+
#nullable disable
|
|
5
|
+
|
|
6
|
+
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|
7
|
+
|
|
8
|
+
namespace Shared.Infrastructure.Migrations
|
|
9
|
+
{
|
|
10
|
+
/// <inheritdoc />
|
|
11
|
+
public partial class SeedInitialData : Migration
|
|
12
|
+
{
|
|
13
|
+
/// <inheritdoc />
|
|
14
|
+
protected override void Up(MigrationBuilder migrationBuilder)
|
|
15
|
+
{
|
|
16
|
+
migrationBuilder.AlterDatabase()
|
|
17
|
+
.Annotation("MySql:CharSet", "utf8mb4");
|
|
18
|
+
|
|
19
|
+
migrationBuilder.CreateTable(
|
|
20
|
+
name: "Item",
|
|
21
|
+
columns: table => new
|
|
22
|
+
{
|
|
23
|
+
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
24
|
+
Status = table.Column<int>(type: "int", nullable: false),
|
|
25
|
+
Date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
26
|
+
Modified = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
27
|
+
},
|
|
28
|
+
constraints: table =>
|
|
29
|
+
{
|
|
30
|
+
table.PrimaryKey("PK_Item", x => x.Id);
|
|
31
|
+
})
|
|
32
|
+
.Annotation("MySql:CharSet", "utf8mb4");
|
|
33
|
+
|
|
34
|
+
migrationBuilder.CreateTable(
|
|
35
|
+
name: "User",
|
|
36
|
+
columns: table => new
|
|
37
|
+
{
|
|
38
|
+
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
39
|
+
Name = table.Column<string>(type: "longtext", nullable: true)
|
|
40
|
+
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
41
|
+
Email = table.Column<string>(type: "longtext", nullable: true)
|
|
42
|
+
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
43
|
+
Picture = table.Column<string>(type: "longtext", nullable: true)
|
|
44
|
+
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
45
|
+
Role = table.Column<int>(type: "int", nullable: false),
|
|
46
|
+
Status = table.Column<int>(type: "int", nullable: false),
|
|
47
|
+
Date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
48
|
+
Modified = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
49
|
+
},
|
|
50
|
+
constraints: table =>
|
|
51
|
+
{
|
|
52
|
+
table.PrimaryKey("PK_User", x => x.Id);
|
|
53
|
+
})
|
|
54
|
+
.Annotation("MySql:CharSet", "utf8mb4");
|
|
55
|
+
|
|
56
|
+
migrationBuilder.InsertData(
|
|
57
|
+
table: "Item",
|
|
58
|
+
columns: new[] { "Id", "Date", "Modified", "Status" },
|
|
59
|
+
values: new object[] { new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 1, 31, 19, 11, 31, 981, DateTimeKind.Local).AddTicks(3227), new DateTime(2026, 1, 31, 19, 11, 31, 981, DateTimeKind.Local).AddTicks(3237), 1 });
|
|
60
|
+
|
|
61
|
+
migrationBuilder.InsertData(
|
|
62
|
+
table: "User",
|
|
63
|
+
columns: new[] { "Id", "Date", "Email", "Modified", "Name", "Picture", "Role", "Status" },
|
|
64
|
+
values: new object[,]
|
|
65
|
+
{
|
|
66
|
+
{ new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(6970), "", new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(6987), "Test", null, 1, 1 },
|
|
67
|
+
{ new Guid("22222222-2222-2222-2222-222222222222"), new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8351), "truongdxfx08031@funix.edu.vn", new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8352), "Truong Dang", null, 0, 1 },
|
|
68
|
+
{ new Guid("33333333-3333-3333-3333-333333333333"), new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8358), "truonghusk17aws1@gmail.com", new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8358), "Thai Son", null, 0, 1 }
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// <inheritdoc />
|
|
73
|
+
protected override void Down(MigrationBuilder migrationBuilder)
|
|
74
|
+
{
|
|
75
|
+
migrationBuilder.DropTable(
|
|
76
|
+
name: "Item");
|
|
77
|
+
|
|
78
|
+
migrationBuilder.DropTable(
|
|
79
|
+
name: "User");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// <auto-generated />
|
|
2
|
+
using System;
|
|
3
|
+
using Microsoft.EntityFrameworkCore;
|
|
4
|
+
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
5
|
+
using Microsoft.EntityFrameworkCore.Metadata;
|
|
6
|
+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
7
|
+
using Shared.Infrastructure;
|
|
8
|
+
|
|
9
|
+
#nullable disable
|
|
10
|
+
|
|
11
|
+
namespace Shared.Infrastructure.Migrations
|
|
12
|
+
{
|
|
13
|
+
[DbContext(typeof(MyDbContext))]
|
|
14
|
+
partial class MyDbContextModelSnapshot : ModelSnapshot
|
|
15
|
+
{
|
|
16
|
+
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
17
|
+
{
|
|
18
|
+
#pragma warning disable 612, 618
|
|
19
|
+
modelBuilder
|
|
20
|
+
.HasAnnotation("ProductVersion", "9.0.0")
|
|
21
|
+
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
|
22
|
+
|
|
23
|
+
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
|
24
|
+
|
|
25
|
+
modelBuilder.Entity("ItemModule.Core.Entities.Item", b =>
|
|
26
|
+
{
|
|
27
|
+
b.Property<Guid>("Id")
|
|
28
|
+
.ValueGeneratedOnAdd()
|
|
29
|
+
.HasColumnType("char(36)");
|
|
30
|
+
|
|
31
|
+
b.Property<DateTime>("Date")
|
|
32
|
+
.HasColumnType("datetime(6)");
|
|
33
|
+
|
|
34
|
+
b.Property<DateTime>("Modified")
|
|
35
|
+
.HasColumnType("datetime(6)");
|
|
36
|
+
|
|
37
|
+
b.Property<int>("Status")
|
|
38
|
+
.HasColumnType("int");
|
|
39
|
+
|
|
40
|
+
b.HasKey("Id");
|
|
41
|
+
|
|
42
|
+
b.ToTable("Item");
|
|
43
|
+
|
|
44
|
+
b.HasData(
|
|
45
|
+
new
|
|
46
|
+
{
|
|
47
|
+
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
48
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 981, DateTimeKind.Local).AddTicks(3227),
|
|
49
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 981, DateTimeKind.Local).AddTicks(3237),
|
|
50
|
+
Status = 1
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
modelBuilder.Entity("UserModule.Core.Entities.User", b =>
|
|
55
|
+
{
|
|
56
|
+
b.Property<Guid>("Id")
|
|
57
|
+
.ValueGeneratedOnAdd()
|
|
58
|
+
.HasColumnType("char(36)");
|
|
59
|
+
|
|
60
|
+
b.Property<DateTime>("Date")
|
|
61
|
+
.HasColumnType("datetime(6)");
|
|
62
|
+
|
|
63
|
+
b.Property<string>("Email")
|
|
64
|
+
.HasColumnType("longtext");
|
|
65
|
+
|
|
66
|
+
b.Property<DateTime>("Modified")
|
|
67
|
+
.HasColumnType("datetime(6)");
|
|
68
|
+
|
|
69
|
+
b.Property<string>("Name")
|
|
70
|
+
.HasColumnType("longtext");
|
|
71
|
+
|
|
72
|
+
b.Property<string>("Picture")
|
|
73
|
+
.HasColumnType("longtext");
|
|
74
|
+
|
|
75
|
+
b.Property<int>("Role")
|
|
76
|
+
.HasColumnType("int");
|
|
77
|
+
|
|
78
|
+
b.Property<int>("Status")
|
|
79
|
+
.HasColumnType("int");
|
|
80
|
+
|
|
81
|
+
b.HasKey("Id");
|
|
82
|
+
|
|
83
|
+
b.ToTable("User");
|
|
84
|
+
|
|
85
|
+
b.HasData(
|
|
86
|
+
new
|
|
87
|
+
{
|
|
88
|
+
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
89
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(6970),
|
|
90
|
+
Email = "",
|
|
91
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(6987),
|
|
92
|
+
Name = "Test",
|
|
93
|
+
Role = 1,
|
|
94
|
+
Status = 1
|
|
95
|
+
},
|
|
96
|
+
new
|
|
97
|
+
{
|
|
98
|
+
Id = new Guid("22222222-2222-2222-2222-222222222222"),
|
|
99
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8351),
|
|
100
|
+
Email = "truongdxfx08031@funix.edu.vn",
|
|
101
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8352),
|
|
102
|
+
Name = "Truong Dang",
|
|
103
|
+
Role = 0,
|
|
104
|
+
Status = 1
|
|
105
|
+
},
|
|
106
|
+
new
|
|
107
|
+
{
|
|
108
|
+
Id = new Guid("33333333-3333-3333-3333-333333333333"),
|
|
109
|
+
Date = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8358),
|
|
110
|
+
Email = "truonghusk17aws1@gmail.com",
|
|
111
|
+
Modified = new DateTime(2026, 1, 31, 19, 11, 31, 979, DateTimeKind.Local).AddTicks(8358),
|
|
112
|
+
Name = "Thai Son",
|
|
113
|
+
Role = 0,
|
|
114
|
+
Status = 1
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
#pragma warning restore 612, 618
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
using Microsoft.EntityFrameworkCore;
|
|
2
|
+
using Shared.Core.Interfaces.SPI;
|
|
3
|
+
|
|
4
|
+
namespace Shared.Infrastructure
|
|
5
|
+
{
|
|
6
|
+
public class MyDbContext : DbContext
|
|
7
|
+
{
|
|
8
|
+
private readonly IEnumerable<IModuleSeeder> _seeders;
|
|
9
|
+
public MyDbContext(
|
|
10
|
+
DbContextOptions<MyDbContext> options,
|
|
11
|
+
IEnumerable<IModuleSeeder> seeders)
|
|
12
|
+
: base(options)
|
|
13
|
+
{
|
|
14
|
+
_seeders = seeders;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
18
|
+
{
|
|
19
|
+
base.OnModelCreating(modelBuilder);
|
|
20
|
+
modelBuilder.ApplyConfigurationsFromAssembly(typeof(MyDbContext).Assembly);
|
|
21
|
+
DbInitializer.Seed(modelBuilder, _seeders);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|