This commit is contained in:
2025-09-05 20:16:58 +04:30
parent f46bb814cc
commit 9b75ddca8a
32 changed files with 660 additions and 125 deletions
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using VizhTalk.Learning.Domain.Entities;
using VizhTalk.Learning.Domain.ValueObjects;
namespace VizhTalk.Learning.Infrastructure.EF.Configurations;
internal class FileGroupConfiguration : IEntityTypeConfiguration<FileGroup>
{
public void Configure(EntityTypeBuilder<FileGroup> builder)
{
builder.ToTable(nameof(FileGroup), Schema.Attachment);
builder.HasKey(x => x.Id);
builder.Property(x => x.Id)
.ValueGeneratedOnAdd()
.HasConversion(x => x.Value, x => new Domain.TypeIds.FileGroupId(x));
builder.Property(x => x.Title)
.HasColumnName("Title")
.HasConversion(x => x.Value, x => new FileGroupTitle(x));
builder.Property(x => x.Key)
.HasColumnName("Key")
.HasMaxLength(150)
.HasConversion(x => x.Value, x => new FileGroupKey(x, null));
}
}
@@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using VizhTalk.Learning.Domain.Entities;
namespace VizhTalk.Learning.Infrastructure.EF.Configurations;
internal class MediaConfiguration : IEntityTypeConfiguration<Media>
{
public void Configure(EntityTypeBuilder<Media> builder)
{
builder.ToTable(nameof(Media), Schema.Learning);
builder.HasKey(x => x.Id);
builder.Property(x => x.Id)
.HasConversion(x => x.Value, x => new Domain.TypeIds.MediaId(x));
builder.Property(x => x.Name)
.HasMaxLength(150);
builder.OwnsOne(x => x.EntityType, op =>
{
op.WithOwner();
op.Property(x => x.Type)
.HasColumnName("EntityType")
.HasMaxLength(200);
op.Property(x => x.EntityId)
.HasColumnName("EntityId")
.HasMaxLength(50);
});
}
}
@@ -9,6 +9,6 @@ namespace VizhTalk.Learning.Infrastructure.EF
public class Schema
{
public const string Learning = "Learning";
public const string Attachment = "Attachment";
}
}
@@ -9,6 +9,7 @@ using VizhTalk.BuildingBlocks.Application.Events;
using VizhTalk.BuildingBlocks.Application.Outbox;
using VizhTalk.BuildingBlocks.Infrastructure;
using VizhTalk.BuildingBlocks.Infrastructure.DomainEventsDispatching;
using VizhTalk.Grpc.CDN;
using VizhTalk.Learning.Application;
using VizhTalk.Learning.Application.Mappers;
using VizhTalk.Learning.Infrastructure.Configuration;
@@ -57,6 +58,11 @@ public static class LearningStartup
MapperConfig.Process();
services.AddGrpcClient<CDNGrpc.CDNGrpcClient>(op =>
{
op.Address = new Uri("https://localhost:5001");
});
services.AddScoped(sa =>
{
var notifications = sa.GetServices<IDomainEventNotification>();
@@ -1,54 +0,0 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using VizhTalk.Learning.Infrastructure.EF;
#nullable disable
namespace VizhTalk.Learning.Infrastructure.Migrations
{
[DbContext(typeof(LearningDbContext))]
[Migration("20250902200044_Inital")]
partial class Inital
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Learning")
.HasAnnotation("ProductVersion", "8.0.19")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Id");
b.ToTable("Languages", "Learning");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,41 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VizhTalk.Learning.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Inital : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Learning");
migrationBuilder.CreateTable(
name: "Languages",
schema: "Learning",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Languages", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Languages",
schema: "Learning");
}
}
}
@@ -0,0 +1,183 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using VizhTalk.Learning.Infrastructure.EF;
#nullable disable
namespace VizhTalk.Learning.Infrastructure.Migrations
{
[DbContext(typeof(LearningDbContext))]
[Migration("20250905153842_initial")]
partial class initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Learning")
.HasAnnotation("ProductVersion", "8.0.19")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsSecure")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)")
.HasColumnName("Key");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<long>("MediaGroupId")
.HasColumnType("bigint");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasColumnName("Title");
b.HasKey("Id");
b.ToTable("FileGroups", "Attachment");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<short>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<Guid>("IconId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Id");
b.HasIndex("IconId");
b.ToTable("Languages", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("ContentType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("Size")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Medias", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
.WithMany()
.HasForeignKey("IconId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Icon");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
{
b.OwnsOne("VizhTalk.Learning.Domain.ValueObjects.EntityType", "EntityType", b1 =>
{
b1.Property<Guid>("MediaId")
.HasColumnType("uniqueidentifier");
b1.Property<string>("EntityId")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("EntityId");
b1.Property<int>("Type")
.HasMaxLength(200)
.HasColumnType("int")
.HasColumnName("EntityType");
b1.HasKey("MediaId");
b1.ToTable("Medias", "Learning");
b1.WithOwner()
.HasForeignKey("MediaId");
});
b.Navigation("EntityType")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,111 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VizhTalk.Learning.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "Attachment");
migrationBuilder.EnsureSchema(
name: "Learning");
migrationBuilder.CreateTable(
name: "FileGroups",
schema: "Attachment",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Key = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
MediaGroupId = table.Column<long>(type: "bigint", nullable: false),
IsSecure = table.Column<bool>(type: "bit", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FileGroups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Medias",
schema: "Learning",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false),
ContentType = table.Column<string>(type: "nvarchar(max)", nullable: false),
Size = table.Column<int>(type: "int", nullable: false),
EntityId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
EntityType = table.Column<int>(type: "int", maxLength: 200, nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medias", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Languages",
schema: "Learning",
columns: table => new
{
Id = table.Column<short>(type: "smallint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false),
IconId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
CreateOn = table.Column<DateTime>(type: "datetime2", nullable: false),
LastUpdate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Languages", x => x.Id);
table.ForeignKey(
name: "FK_Languages_Medias_IconId",
column: x => x.IconId,
principalSchema: "Learning",
principalTable: "Medias",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Languages_IconId",
schema: "Learning",
table: "Languages",
column: "IconId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FileGroups",
schema: "Attachment");
migrationBuilder.DropTable(
name: "Languages",
schema: "Learning");
migrationBuilder.DropTable(
name: "Medias",
schema: "Learning");
}
}
}
@@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -22,13 +23,16 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.FileGroup", b =>
{
b.Property<int>("Id")
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<bool>("IsActive")
.HasColumnType("bit");
@@ -36,6 +40,54 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsSecure")
.HasColumnType("bit");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)")
.HasColumnName("Key");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<long>("MediaGroupId")
.HasColumnType("bigint");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasColumnName("Title");
b.HasKey("Id");
b.ToTable("FileGroups", "Attachment");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.Property<short>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("smallint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<short>("Id"));
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<Guid>("IconId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(60)
@@ -43,8 +95,85 @@ namespace VizhTalk.Learning.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("IconId");
b.ToTable("Languages", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("ContentType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreateOn")
.HasColumnType("datetime2");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastUpdate")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<int>("Size")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Medias", "Learning");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Language", b =>
{
b.HasOne("VizhTalk.Learning.Domain.Entities.Media", "Icon")
.WithMany()
.HasForeignKey("IconId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Icon");
});
modelBuilder.Entity("VizhTalk.Learning.Domain.Entities.Media", b =>
{
b.OwnsOne("VizhTalk.Learning.Domain.ValueObjects.EntityType", "EntityType", b1 =>
{
b1.Property<Guid>("MediaId")
.HasColumnType("uniqueidentifier");
b1.Property<string>("EntityId")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("EntityId");
b1.Property<int>("Type")
.HasMaxLength(200)
.HasColumnType("int")
.HasColumnName("EntityType");
b1.HasKey("MediaId");
b1.ToTable("Medias", "Learning");
b1.WithOwner()
.HasForeignKey("MediaId");
});
b.Navigation("EntityType")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
@@ -7,7 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="Grpc.AspNetCore" Version="2.57.0" />
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.19">
<PrivateAssets>all</PrivateAssets>