netcore-blueprint 0.0.60 → 0.0.62
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/Host.API.csproj +0 -3
- package/BlueprintTemplate/Host.API/appsettings.json +1 -1
- package/BlueprintTemplate/MyBlueprint.slnx +0 -5
- package/BlueprintTemplate/Shared.Infrastructure/Migrations/{20260208002409_SeedInitialData.Designer.cs → 20260210145611_SeedInitialData.Designer.cs} +9 -38
- package/BlueprintTemplate/Shared.Infrastructure/Migrations/{20260208002409_SeedInitialData.cs → 20260210145611_SeedInitialData.cs} +4 -27
- package/BlueprintTemplate/Shared.Infrastructure/Migrations/MyDbContextModelSnapshot.cs +8 -37
- package/README.md +25 -2
- package/bin/copy-module.js +7 -6
- package/package.json +1 -1
- package/BlueprintTemplate/ItemModule.API/Controllers/Public/ItemController.cs +0 -65
- package/BlueprintTemplate/ItemModule.API/ItemModule.API.csproj +0 -27
- package/BlueprintTemplate/ItemModule.API/ItemModule.cs +0 -24
- package/BlueprintTemplate/ItemModule.API/Mappers/DtoItemMappingProfile.cs +0 -26
- package/BlueprintTemplate/ItemModule.Core/Dtos/Admin/ItemRequestDto.cs +0 -8
- package/BlueprintTemplate/ItemModule.Core/Dtos/Admin/ItemResponseDto.cs +0 -8
- package/BlueprintTemplate/ItemModule.Core/Entities/Item.cs +0 -8
- package/BlueprintTemplate/ItemModule.Core/Interfaces/API/IItemService.cs +0 -9
- package/BlueprintTemplate/ItemModule.Core/Interfaces/SPI/IItemInfra.cs +0 -9
- package/BlueprintTemplate/ItemModule.Core/ItemCoreDependencyInjection.cs +0 -19
- package/BlueprintTemplate/ItemModule.Core/ItemModule.Core.csproj +0 -18
- package/BlueprintTemplate/ItemModule.Core/Services/ItemService.cs +0 -20
- package/BlueprintTemplate/ItemModule.Infrastructure/Database/ItemConfiguration.cs +0 -22
- package/BlueprintTemplate/ItemModule.Infrastructure/Database/Seeder.cs +0 -21
- package/BlueprintTemplate/ItemModule.Infrastructure/ItemInfraDependencyInjection.cs +0 -21
- package/BlueprintTemplate/ItemModule.Infrastructure/ItemModule.Infrastructure.csproj +0 -14
- package/BlueprintTemplate/ItemModule.Infrastructure/Services/MySQLItemInfra.cs +0 -16
- package/BlueprintTemplate/README.md +0 -28
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
</ItemGroup>
|
|
17
17
|
|
|
18
18
|
<ItemGroup>
|
|
19
|
-
<ProjectReference Include="..\ItemModule.API\ItemModule.API.csproj" />
|
|
20
|
-
<ProjectReference Include="..\ItemModule.Core\ItemModule.Core.csproj" />
|
|
21
|
-
<ProjectReference Include="..\ItemModule.Infrastructure\ItemModule.Infrastructure.csproj" />
|
|
22
19
|
<ProjectReference Include="..\Modules\__MODULE__Module\__MODULE__Module.API\__MODULE__Module.API.csproj" />
|
|
23
20
|
<ProjectReference Include="..\Modules\__MODULE__Module\__MODULE__Module.Core\__MODULE__Module.Core.csproj" />
|
|
24
21
|
<ProjectReference Include="..\Modules\__MODULE__Module\__MODULE__Module.Infrastructure\__MODULE__Module.Infrastructure.csproj" />
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
<Project Path="Host.API/Host.API.csproj" />
|
|
4
4
|
</Folder>
|
|
5
5
|
<Folder Name="/Modules/" />
|
|
6
|
-
<Folder Name="/Modules/ItemModule/">
|
|
7
|
-
<Project Path="ItemModule.API/ItemModule.API.csproj" Id="c57fa45b-2f29-43e5-b170-35ed55caec58" />
|
|
8
|
-
<Project Path="ItemModule.Core/ItemModule.Core.csproj" Id="d2c886fa-7941-46a2-bf70-c1bc63fe3ce4" />
|
|
9
|
-
<Project Path="ItemModule.Infrastructure/ItemModule.Infrastructure.csproj" Id="617cb286-de79-466b-b1bf-b103dfc716ec" />
|
|
10
|
-
</Folder>
|
|
11
6
|
<Folder Name="/Modules/UserModule/">
|
|
12
7
|
<Project Path="User.API/UserModule.API.csproj" />
|
|
13
8
|
<Project Path="User.Core/UserModule.Core.csproj" />
|
|
@@ -12,7 +12,7 @@ using Shared.Infrastructure.Database;
|
|
|
12
12
|
namespace Shared.Infrastructure.Migrations
|
|
13
13
|
{
|
|
14
14
|
[DbContext(typeof(MyDbContext))]
|
|
15
|
-
[Migration("
|
|
15
|
+
[Migration("20260210145611_SeedInitialData")]
|
|
16
16
|
partial class SeedInitialData
|
|
17
17
|
{
|
|
18
18
|
/// <inheritdoc />
|
|
@@ -25,35 +25,6 @@ namespace Shared.Infrastructure.Migrations
|
|
|
25
25
|
|
|
26
26
|
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
|
27
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, 2, 8, 7, 24, 8, 369, DateTimeKind.Local).AddTicks(9065),
|
|
52
|
-
Modified = new DateTime(2026, 2, 8, 7, 24, 8, 369, DateTimeKind.Local).AddTicks(9084),
|
|
53
|
-
Status = 1
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
28
|
modelBuilder.Entity("UserModule.Core.Entities.User", b =>
|
|
58
29
|
{
|
|
59
30
|
b.Property<Guid>("Id")
|
|
@@ -89,9 +60,9 @@ namespace Shared.Infrastructure.Migrations
|
|
|
89
60
|
new
|
|
90
61
|
{
|
|
91
62
|
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
92
|
-
Date = new DateTime(2026, 2,
|
|
63
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(5286),
|
|
93
64
|
Email = "",
|
|
94
|
-
Modified = new DateTime(2026, 2,
|
|
65
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(5300),
|
|
95
66
|
Name = "Test",
|
|
96
67
|
Role = 1,
|
|
97
68
|
Status = 1
|
|
@@ -99,9 +70,9 @@ namespace Shared.Infrastructure.Migrations
|
|
|
99
70
|
new
|
|
100
71
|
{
|
|
101
72
|
Id = new Guid("22222222-2222-2222-2222-222222222222"),
|
|
102
|
-
Date = new DateTime(2026, 2,
|
|
73
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6780),
|
|
103
74
|
Email = "truongdxfx08031@funix.edu.vn",
|
|
104
|
-
Modified = new DateTime(2026, 2,
|
|
75
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6782),
|
|
105
76
|
Name = "Truong Dang",
|
|
106
77
|
Role = 0,
|
|
107
78
|
Status = 1
|
|
@@ -109,9 +80,9 @@ namespace Shared.Infrastructure.Migrations
|
|
|
109
80
|
new
|
|
110
81
|
{
|
|
111
82
|
Id = new Guid("33333333-3333-3333-3333-333333333333"),
|
|
112
|
-
Date = new DateTime(2026, 2,
|
|
83
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6788),
|
|
113
84
|
Email = "truonghusk17aws1@gmail.com",
|
|
114
|
-
Modified = new DateTime(2026, 2,
|
|
85
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6789),
|
|
115
86
|
Name = "Thai Son",
|
|
116
87
|
Role = 0,
|
|
117
88
|
Status = 1
|
|
@@ -141,8 +112,8 @@ namespace Shared.Infrastructure.Migrations
|
|
|
141
112
|
new
|
|
142
113
|
{
|
|
143
114
|
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
144
|
-
Date = new DateTime(2026, 2,
|
|
145
|
-
Modified = new DateTime(2026, 2,
|
|
115
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 155, DateTimeKind.Local).AddTicks(6644),
|
|
116
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 155, DateTimeKind.Local).AddTicks(6652),
|
|
146
117
|
Status = 1
|
|
147
118
|
});
|
|
148
119
|
});
|
|
@@ -31,21 +31,6 @@ namespace Shared.Infrastructure.Migrations
|
|
|
31
31
|
})
|
|
32
32
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
33
33
|
|
|
34
|
-
migrationBuilder.CreateTable(
|
|
35
|
-
name: "Item",
|
|
36
|
-
columns: table => new
|
|
37
|
-
{
|
|
38
|
-
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
39
|
-
Status = table.Column<int>(type: "int", nullable: false),
|
|
40
|
-
Date = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
41
|
-
Modified = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
42
|
-
},
|
|
43
|
-
constraints: table =>
|
|
44
|
-
{
|
|
45
|
-
table.PrimaryKey("PK_Item", x => x.Id);
|
|
46
|
-
})
|
|
47
|
-
.Annotation("MySql:CharSet", "utf8mb4");
|
|
48
|
-
|
|
49
34
|
migrationBuilder.CreateTable(
|
|
50
35
|
name: "User",
|
|
51
36
|
columns: table => new
|
|
@@ -68,25 +53,20 @@ namespace Shared.Infrastructure.Migrations
|
|
|
68
53
|
})
|
|
69
54
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
70
55
|
|
|
71
|
-
migrationBuilder.InsertData(
|
|
72
|
-
table: "Item",
|
|
73
|
-
columns: new[] { "Id", "Date", "Modified", "Status" },
|
|
74
|
-
values: new object[] { new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 2, 8, 7, 24, 8, 369, DateTimeKind.Local).AddTicks(9065), new DateTime(2026, 2, 8, 7, 24, 8, 369, DateTimeKind.Local).AddTicks(9084), 1 });
|
|
75
|
-
|
|
76
56
|
migrationBuilder.InsertData(
|
|
77
57
|
table: "User",
|
|
78
58
|
columns: new[] { "Id", "Date", "Email", "Modified", "Name", "Picture", "Role", "Status" },
|
|
79
59
|
values: new object[,]
|
|
80
60
|
{
|
|
81
|
-
{ new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 2,
|
|
82
|
-
{ new Guid("22222222-2222-2222-2222-222222222222"), new DateTime(2026, 2,
|
|
83
|
-
{ new Guid("33333333-3333-3333-3333-333333333333"), new DateTime(2026, 2,
|
|
61
|
+
{ new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(5286), "", new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(5300), "Test", null, 1, 1 },
|
|
62
|
+
{ new Guid("22222222-2222-2222-2222-222222222222"), new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6780), "truongdxfx08031@funix.edu.vn", new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6782), "Truong Dang", null, 0, 1 },
|
|
63
|
+
{ new Guid("33333333-3333-3333-3333-333333333333"), new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6788), "truonghusk17aws1@gmail.com", new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6789), "Thai Son", null, 0, 1 }
|
|
84
64
|
});
|
|
85
65
|
|
|
86
66
|
migrationBuilder.InsertData(
|
|
87
67
|
table: "__MODULE__",
|
|
88
68
|
columns: new[] { "Id", "Date", "Modified", "Status" },
|
|
89
|
-
values: new object[] { new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 2,
|
|
69
|
+
values: new object[] { new Guid("11111111-1111-1111-1111-111111111111"), new DateTime(2026, 2, 10, 21, 56, 10, 155, DateTimeKind.Local).AddTicks(6644), new DateTime(2026, 2, 10, 21, 56, 10, 155, DateTimeKind.Local).AddTicks(6652), 1 });
|
|
90
70
|
}
|
|
91
71
|
|
|
92
72
|
/// <inheritdoc />
|
|
@@ -95,9 +75,6 @@ namespace Shared.Infrastructure.Migrations
|
|
|
95
75
|
migrationBuilder.DropTable(
|
|
96
76
|
name: "__MODULE__");
|
|
97
77
|
|
|
98
|
-
migrationBuilder.DropTable(
|
|
99
|
-
name: "Item");
|
|
100
|
-
|
|
101
78
|
migrationBuilder.DropTable(
|
|
102
79
|
name: "User");
|
|
103
80
|
}
|
|
@@ -22,35 +22,6 @@ namespace Shared.Infrastructure.Migrations
|
|
|
22
22
|
|
|
23
23
|
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
|
|
24
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, 2, 8, 7, 24, 8, 369, DateTimeKind.Local).AddTicks(9065),
|
|
49
|
-
Modified = new DateTime(2026, 2, 8, 7, 24, 8, 369, DateTimeKind.Local).AddTicks(9084),
|
|
50
|
-
Status = 1
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
25
|
modelBuilder.Entity("UserModule.Core.Entities.User", b =>
|
|
55
26
|
{
|
|
56
27
|
b.Property<Guid>("Id")
|
|
@@ -86,9 +57,9 @@ namespace Shared.Infrastructure.Migrations
|
|
|
86
57
|
new
|
|
87
58
|
{
|
|
88
59
|
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
89
|
-
Date = new DateTime(2026, 2,
|
|
60
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(5286),
|
|
90
61
|
Email = "",
|
|
91
|
-
Modified = new DateTime(2026, 2,
|
|
62
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(5300),
|
|
92
63
|
Name = "Test",
|
|
93
64
|
Role = 1,
|
|
94
65
|
Status = 1
|
|
@@ -96,9 +67,9 @@ namespace Shared.Infrastructure.Migrations
|
|
|
96
67
|
new
|
|
97
68
|
{
|
|
98
69
|
Id = new Guid("22222222-2222-2222-2222-222222222222"),
|
|
99
|
-
Date = new DateTime(2026, 2,
|
|
70
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6780),
|
|
100
71
|
Email = "truongdxfx08031@funix.edu.vn",
|
|
101
|
-
Modified = new DateTime(2026, 2,
|
|
72
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6782),
|
|
102
73
|
Name = "Truong Dang",
|
|
103
74
|
Role = 0,
|
|
104
75
|
Status = 1
|
|
@@ -106,9 +77,9 @@ namespace Shared.Infrastructure.Migrations
|
|
|
106
77
|
new
|
|
107
78
|
{
|
|
108
79
|
Id = new Guid("33333333-3333-3333-3333-333333333333"),
|
|
109
|
-
Date = new DateTime(2026, 2,
|
|
80
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6788),
|
|
110
81
|
Email = "truonghusk17aws1@gmail.com",
|
|
111
|
-
Modified = new DateTime(2026, 2,
|
|
82
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 153, DateTimeKind.Local).AddTicks(6789),
|
|
112
83
|
Name = "Thai Son",
|
|
113
84
|
Role = 0,
|
|
114
85
|
Status = 1
|
|
@@ -138,8 +109,8 @@ namespace Shared.Infrastructure.Migrations
|
|
|
138
109
|
new
|
|
139
110
|
{
|
|
140
111
|
Id = new Guid("11111111-1111-1111-1111-111111111111"),
|
|
141
|
-
Date = new DateTime(2026, 2,
|
|
142
|
-
Modified = new DateTime(2026, 2,
|
|
112
|
+
Date = new DateTime(2026, 2, 10, 21, 56, 10, 155, DateTimeKind.Local).AddTicks(6644),
|
|
113
|
+
Modified = new DateTime(2026, 2, 10, 21, 56, 10, 155, DateTimeKind.Local).AddTicks(6652),
|
|
143
114
|
Status = 1
|
|
144
115
|
});
|
|
145
116
|
});
|
package/README.md
CHANGED
|
@@ -3,6 +3,29 @@ How to make a blueprint
|
|
|
3
3
|
- npm uninstall -g netcore-blueprint
|
|
4
4
|
- npm install -g netcore-blueprint
|
|
5
5
|
- npm list -g netcore-blueprint
|
|
6
|
-
- create-app <AppName>
|
|
6
|
+
- create-app <AppName> (Sửa connection string)
|
|
7
7
|
- create-module <ModuleName> <EntityName>
|
|
8
|
-
- copy-module <CopiedModuleName> (Run
|
|
8
|
+
- copy-module <CopiedModuleName> (Run in the folder Modules right outside the solution) (copy-module <CopiedModuleName> --force)
|
|
9
|
+
|
|
10
|
+
2. Tạo mới 1 module
|
|
11
|
+
- Copy lại thư mục item để thêm module mới
|
|
12
|
+
- Sửa lại tên và toàn bộ namespace
|
|
13
|
+
- Thêm ref vào Host.API
|
|
14
|
+
- Bật tắt các module không cần thiết
|
|
15
|
+
- Bật tắt hoặc chuyển đổi DB nếu cần
|
|
16
|
+
|
|
17
|
+
3. Bỏ module
|
|
18
|
+
- Xóa module
|
|
19
|
+
- Bỏ <Folder Name="/Modules/ProductModule/"> ở MyBlueprint.slnx
|
|
20
|
+
- Bỏ ProjectReference ở Host.API.csproj
|
|
21
|
+
|
|
22
|
+
4. Mock Data
|
|
23
|
+
- Tools → NuGet Package Manager → Package Manager Console
|
|
24
|
+
- Default project: catalog.Infra
|
|
25
|
+
- Xóa Migration cũ
|
|
26
|
+
- Add-Migration SeedInitialData
|
|
27
|
+
- Update-Database
|
|
28
|
+
|
|
29
|
+
5. Todos
|
|
30
|
+
- Plug/ Unplug module (config)
|
|
31
|
+
- Plug/ Unplug database provider (config)
|
package/bin/copy-module.js
CHANGED
|
@@ -263,13 +263,14 @@ function addModuleReferencesToHostApi(moduleName, hostApiCsprojPath) {
|
|
|
263
263
|
.map(r => ` <ProjectReference Include="${r}" />`)
|
|
264
264
|
.join('\n');
|
|
265
265
|
|
|
266
|
-
//
|
|
267
|
-
const
|
|
266
|
+
// 🔥 Find ItemGroup that has ProjectReference BUT NOT PackageReference
|
|
267
|
+
const projectOnlyItemGroupRegex =
|
|
268
|
+
/<ItemGroup>(?:(?!<PackageReference)[\s\S])*?<ProjectReference[\s\S]*?<\/ItemGroup>/;
|
|
268
269
|
|
|
269
|
-
const match = content.match(
|
|
270
|
+
const match = content.match(projectOnlyItemGroupRegex);
|
|
270
271
|
|
|
271
272
|
if (match) {
|
|
272
|
-
// ✅ Append to
|
|
273
|
+
// ✅ Append to correct ProjectReference-only ItemGroup
|
|
273
274
|
const originalGroup = match[0];
|
|
274
275
|
|
|
275
276
|
const updatedGroup = originalGroup.replace(
|
|
@@ -279,9 +280,9 @@ function addModuleReferencesToHostApi(moduleName, hostApiCsprojPath) {
|
|
|
279
280
|
|
|
280
281
|
content = content.replace(originalGroup, updatedGroup);
|
|
281
282
|
|
|
282
|
-
console.log(`✅ Appended
|
|
283
|
+
console.log(`✅ Appended to ProjectReference-only ItemGroup`);
|
|
283
284
|
} else {
|
|
284
|
-
// 🆕
|
|
285
|
+
// 🆕 Fallback: create new clean ProjectReference ItemGroup
|
|
285
286
|
const newItemGroup = `
|
|
286
287
|
|
|
287
288
|
<ItemGroup>
|
package/package.json
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
using AutoMapper;
|
|
2
|
-
using ItemModule.Core.Dtos.Admin;
|
|
3
|
-
using ItemModule.Core.Entities;
|
|
4
|
-
using ItemModule.Core.Interfaces.API;
|
|
5
|
-
using Microsoft.AspNetCore.Http;
|
|
6
|
-
using Microsoft.AspNetCore.Mvc;
|
|
7
|
-
using Microsoft.Extensions.Logging;
|
|
8
|
-
using Shared.Core.Shared.Models;
|
|
9
|
-
using System.Diagnostics;
|
|
10
|
-
|
|
11
|
-
namespace ItemModule.API.Controllers.Public
|
|
12
|
-
{
|
|
13
|
-
/// <summary>
|
|
14
|
-
/// Item Controller
|
|
15
|
-
/// </summary>
|
|
16
|
-
[Route("rest/v{version:apiVersion}/items")]
|
|
17
|
-
[Produces("application/json")]
|
|
18
|
-
[ApiController]
|
|
19
|
-
public class ItemController : Controller
|
|
20
|
-
{
|
|
21
|
-
private readonly IMapper _mapper;
|
|
22
|
-
private ILogger _logger;
|
|
23
|
-
private readonly IItemService _itemService;
|
|
24
|
-
|
|
25
|
-
/// <summary>
|
|
26
|
-
/// Constructor
|
|
27
|
-
/// </summary>
|
|
28
|
-
/// <param name="logger"></param>
|
|
29
|
-
/// <param name="mapper"></param>
|
|
30
|
-
/// <param name="itemService"></param>
|
|
31
|
-
public ItemController(
|
|
32
|
-
ILogger<ItemController> logger,
|
|
33
|
-
IMapper mapper,
|
|
34
|
-
IItemService itemService)
|
|
35
|
-
{
|
|
36
|
-
_mapper = mapper;
|
|
37
|
-
_logger = logger;
|
|
38
|
-
_itemService = itemService;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/// <summary>
|
|
42
|
-
/// Get items
|
|
43
|
-
/// </summary>
|
|
44
|
-
/// <param name="pagingParams"></param>
|
|
45
|
-
/// <returns></returns>
|
|
46
|
-
[HttpGet]
|
|
47
|
-
[ProducesResponseType(typeof(PagerData<ItemResponseDto>), StatusCodes.Status200OK)]
|
|
48
|
-
public async Task<IActionResult> GetItems([FromQuery] PagingParams pagingParams)
|
|
49
|
-
{
|
|
50
|
-
_logger.LogInformation($"Start getting items");
|
|
51
|
-
var stopwatch = Stopwatch.StartNew();
|
|
52
|
-
|
|
53
|
-
PagerData<Item> items = await _itemService.GetItemsAsync(pagingParams);
|
|
54
|
-
PagerData<ItemResponseDto> itemResponse = _mapper.Map<PagerData<ItemResponseDto>>(items);
|
|
55
|
-
|
|
56
|
-
// Add custom headers
|
|
57
|
-
Response.Headers.Append("X-WP-Total", items.TotalRecords.ToString());
|
|
58
|
-
|
|
59
|
-
stopwatch.Stop();
|
|
60
|
-
_logger.LogInformation($"Getting items done in {stopwatch.ElapsedMilliseconds}");
|
|
61
|
-
|
|
62
|
-
return Ok(itemResponse.Items);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
<Folder Include="Controllers\Admin\" />
|
|
11
|
-
</ItemGroup>
|
|
12
|
-
|
|
13
|
-
<ItemGroup>
|
|
14
|
-
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.1" />
|
|
15
|
-
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.1" />
|
|
16
|
-
<PackageReference Include="AutoMapper" Version="16.0.0" />
|
|
17
|
-
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="10.0.2" />
|
|
18
|
-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.9" />
|
|
19
|
-
</ItemGroup>
|
|
20
|
-
|
|
21
|
-
<ItemGroup>
|
|
22
|
-
<ProjectReference Include="..\ItemModule.Core\ItemModule.Core.csproj" />
|
|
23
|
-
<ProjectReference Include="..\ItemModule.Infrastructure\ItemModule.Infrastructure.csproj" />
|
|
24
|
-
<ProjectReference Include="..\Shared.Core\Shared.Core.csproj" />
|
|
25
|
-
</ItemGroup>
|
|
26
|
-
|
|
27
|
-
</Project>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
using ItemModule.API.Controllers.Public;
|
|
2
|
-
using ItemModule.API.Mappers;
|
|
3
|
-
using ItemModule.Core;
|
|
4
|
-
using ItemModule.Infrastructure;
|
|
5
|
-
using Microsoft.Extensions.Configuration;
|
|
6
|
-
using Microsoft.Extensions.DependencyInjection;
|
|
7
|
-
using Shared.Core.Interfaces.Modules;
|
|
8
|
-
using System.Reflection;
|
|
9
|
-
|
|
10
|
-
namespace ItemModule.API
|
|
11
|
-
{
|
|
12
|
-
public class ItemModule : IModule
|
|
13
|
-
{
|
|
14
|
-
public string Name => "Item";
|
|
15
|
-
public void Register(IServiceCollection services, IConfiguration config)
|
|
16
|
-
{
|
|
17
|
-
ItemCoreDependencyInjection.AddModule(services);
|
|
18
|
-
ItemInfraDependencyInjection.AddModule(services);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public Assembly ApiAssembly => typeof(ItemController).Assembly;
|
|
22
|
-
public Assembly MappingAssembly => typeof(DtoItemMappingProfile).Assembly;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
using AutoMapper;
|
|
2
|
-
using ItemModule.Core.Dtos.Admin;
|
|
3
|
-
using ItemModule.Core.Entities;
|
|
4
|
-
using Shared.Core.Shared.Models;
|
|
5
|
-
|
|
6
|
-
namespace ItemModule.API.Mappers
|
|
7
|
-
{
|
|
8
|
-
/// <summary>
|
|
9
|
-
/// DtoItemMappingProfile
|
|
10
|
-
/// </summary>
|
|
11
|
-
public class DtoItemMappingProfile : Profile
|
|
12
|
-
{
|
|
13
|
-
/// <summary>
|
|
14
|
-
/// Constructor
|
|
15
|
-
/// </summary>
|
|
16
|
-
public DtoItemMappingProfile()
|
|
17
|
-
{
|
|
18
|
-
CreateMap<Item, ItemRequestDto>().ReverseMap();
|
|
19
|
-
|
|
20
|
-
CreateMap<PagerData<Item>, PagerData<ItemResponseDto>>().ReverseMap();
|
|
21
|
-
|
|
22
|
-
CreateMap<Item, ItemResponseDto>()
|
|
23
|
-
.ReverseMap();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
using ItemModule.Core.Interfaces.API;
|
|
2
|
-
using ItemModule.Core.Services;
|
|
3
|
-
using Microsoft.Extensions.DependencyInjection;
|
|
4
|
-
using Shared.Core.Interfaces.API;
|
|
5
|
-
using Shared.Core.Services;
|
|
6
|
-
|
|
7
|
-
namespace ItemModule.Core
|
|
8
|
-
{
|
|
9
|
-
public static class ItemCoreDependencyInjection
|
|
10
|
-
{
|
|
11
|
-
public static IServiceCollection AddModule(
|
|
12
|
-
this IServiceCollection services)
|
|
13
|
-
{
|
|
14
|
-
services.AddScoped(typeof(IItemService<>), typeof(ItemService<>));
|
|
15
|
-
services.AddScoped<IItemService, ItemService>();
|
|
16
|
-
return services;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
<ProjectReference Include="..\Shared.Core\Shared.Core.csproj" />
|
|
11
|
-
</ItemGroup>
|
|
12
|
-
|
|
13
|
-
<ItemGroup>
|
|
14
|
-
<Folder Include="Dtos\Public\" />
|
|
15
|
-
<Folder Include="Enums\" />
|
|
16
|
-
</ItemGroup>
|
|
17
|
-
|
|
18
|
-
</Project>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
using ItemModule.Core.Entities;
|
|
2
|
-
using ItemModule.Core.Interfaces.API;
|
|
3
|
-
using ItemModule.Core.Interfaces.SPI;
|
|
4
|
-
using Microsoft.Extensions.Logging;
|
|
5
|
-
using Shared.Core.Interfaces.SPI;
|
|
6
|
-
using Shared.Core.Services;
|
|
7
|
-
|
|
8
|
-
namespace ItemModule.Core.Services
|
|
9
|
-
{
|
|
10
|
-
public class ItemService : ItemService<Item>, IItemService
|
|
11
|
-
{
|
|
12
|
-
private readonly IItemInfra _userInfra;
|
|
13
|
-
public ItemService(ILogger<ItemService> logger,
|
|
14
|
-
IRepositoryFactory<Item> repositoryFactory,
|
|
15
|
-
IItemInfra userInfra) : base(logger, repositoryFactory)
|
|
16
|
-
{
|
|
17
|
-
_userInfra = userInfra;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
using ItemModule.Core.Entities;
|
|
2
|
-
using Microsoft.EntityFrameworkCore;
|
|
3
|
-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
4
|
-
|
|
5
|
-
namespace ItemModule.Infrastructure.Database
|
|
6
|
-
{
|
|
7
|
-
internal class ItemConfiguration : IEntityTypeConfiguration<Item>
|
|
8
|
-
{
|
|
9
|
-
public void Configure(EntityTypeBuilder<Item> builder)
|
|
10
|
-
{
|
|
11
|
-
// Table
|
|
12
|
-
builder.ToTable("Items");
|
|
13
|
-
|
|
14
|
-
// Primary key
|
|
15
|
-
builder.HasKey(x => x.Id);
|
|
16
|
-
|
|
17
|
-
// BaseEntity (nếu có)
|
|
18
|
-
builder.Property(x => x.Id)
|
|
19
|
-
.IsRequired();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
using ItemModule.Core.Entities;
|
|
2
|
-
using Microsoft.EntityFrameworkCore;
|
|
3
|
-
using Shared.Core.Enums;
|
|
4
|
-
using Shared.Core.Interfaces.SPI;
|
|
5
|
-
|
|
6
|
-
namespace ItemModule.Infrastructure.Database
|
|
7
|
-
{
|
|
8
|
-
public class Seeder : IModuleSeeder
|
|
9
|
-
{
|
|
10
|
-
public void Seed(ModelBuilder modelBuilder)
|
|
11
|
-
{
|
|
12
|
-
modelBuilder.Entity<Item>().HasData(
|
|
13
|
-
new Item
|
|
14
|
-
{
|
|
15
|
-
Id = Guid.Parse("11111111-1111-1111-1111-111111111111"),
|
|
16
|
-
Status = EntityStatus.Active,
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
using ItemModule.Core.Interfaces.SPI;
|
|
2
|
-
using ItemModule.Infrastructure.Database;
|
|
3
|
-
using ItemModule.Infrastructure.Services;
|
|
4
|
-
using Microsoft.Extensions.DependencyInjection;
|
|
5
|
-
using Shared.Core.Interfaces.SPI;
|
|
6
|
-
using Shared.Infrastructure.Services.MySQL;
|
|
7
|
-
|
|
8
|
-
namespace ItemModule.Infrastructure
|
|
9
|
-
{
|
|
10
|
-
public static class ItemInfraDependencyInjection
|
|
11
|
-
{
|
|
12
|
-
public static IServiceCollection AddModule(
|
|
13
|
-
this IServiceCollection services)
|
|
14
|
-
{
|
|
15
|
-
services.AddScoped<IModuleSeeder, Seeder>();
|
|
16
|
-
services.AddScoped<IItemInfra, MySQLItemInfra>();
|
|
17
|
-
services.AddScoped(typeof(IItemInfra<>), typeof(MySQLItemInfra<>));
|
|
18
|
-
return services;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
<ProjectReference Include="..\ItemModule.Core\ItemModule.Core.csproj" />
|
|
11
|
-
<ProjectReference Include="..\Shared.Infrastructure\Shared.Infrastructure.csproj" />
|
|
12
|
-
</ItemGroup>
|
|
13
|
-
|
|
14
|
-
</Project>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
using ItemModule.Core.Entities;
|
|
2
|
-
using ItemModule.Core.Interfaces.SPI;
|
|
3
|
-
using Microsoft.Extensions.Logging;
|
|
4
|
-
using Shared.Infrastructure.Database;
|
|
5
|
-
using Shared.Infrastructure.Services.MySQL;
|
|
6
|
-
|
|
7
|
-
namespace ItemModule.Infrastructure.Services
|
|
8
|
-
{
|
|
9
|
-
public class MySQLItemInfra : MySQLItemInfra<Item>, IItemInfra
|
|
10
|
-
{
|
|
11
|
-
public MySQLItemInfra(MyDbContext dbContext, ILogger<MySQLItemInfra> logger)
|
|
12
|
-
: base(dbContext, logger)
|
|
13
|
-
{
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
5. Tạo mới 1 project từ module:
|
|
2
|
-
- Chạy câu lệnh blueprint
|
|
3
|
-
|
|
4
|
-
- Sửa connection string (nếu cần)
|
|
5
|
-
- dotnet restore
|
|
6
|
-
|
|
7
|
-
6. Tạo mới 1 module
|
|
8
|
-
- Copy lại thư mục item để thêm module mới
|
|
9
|
-
- Sửa lại tên và toàn bộ namespace
|
|
10
|
-
- Thêm ref vào Host.API
|
|
11
|
-
- Bật tắt các module không cần thiết
|
|
12
|
-
- Bật tắt hoặc chuyển đổi DB nếu cần
|
|
13
|
-
|
|
14
|
-
7. Mock Data
|
|
15
|
-
- Tools → NuGet Package Manager → Package Manager Console
|
|
16
|
-
- Default project: catalog.Infra
|
|
17
|
-
- Xóa Migration cũ
|
|
18
|
-
- Add-Migration SeedInitialData
|
|
19
|
-
- Update-Database
|
|
20
|
-
|
|
21
|
-
8. Todos
|
|
22
|
-
- Plug/ Unplug module (config)
|
|
23
|
-
- Plug/ Unplug database provider (config)
|
|
24
|
-
- Thay module mẫu bằng __MODULE__, test bằng việc tạo Product, Category
|
|
25
|
-
|
|
26
|
-
(Chỉnh sửa khi làm Mock back-end)
|
|
27
|
-
- Channge DB to NoSQL
|
|
28
|
-
- Simple infra for DocumentDb and Lambda
|