Страница профиля

This commit is contained in:
Халимов Рустам
2026-02-13 14:24:01 +03:00
parent b24b9d697f
commit 1e72d006c4
34 changed files with 1169 additions and 27 deletions
@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Nashel.Modules.Identity.Domain.Entities;
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Configurations;
public class CompetencyConfiguration : IEntityTypeConfiguration<Competency>
{
public void Configure(EntityTypeBuilder<Competency> builder)
{
builder.ToTable("Competencies", "identity");
builder.HasKey(x => x.Id);
builder.Property(x => x.Name)
.IsRequired()
.HasMaxLength(100);
// Unique index on Name (case-insensitive)
builder.HasIndex(x => x.Name)
.IsUnique()
.HasDatabaseName("IX_Competencies_Name");
}
}
@@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Nashel.BuildingBlocks.Domain;
using Nashel.Modules.Identity.Domain.Aggregates;
using Nashel.Modules.Identity.Domain.Entities;
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Configurations;
public class UserProfileConfiguration : IEntityTypeConfiguration<UserProfile>
{
public void Configure(EntityTypeBuilder<UserProfile> builder)
{
builder.ToTable("UserProfiles", "identity");
builder.HasKey(x => x.Id);
builder.Property(x => x.FirstName)
.IsRequired()
.HasMaxLength(100);
builder.Property(x => x.LastName)
.IsRequired()
.HasMaxLength(100);
builder.Property(x => x.Patronymic)
.HasMaxLength(100);
builder.Property(x => x.CompanyName)
.HasMaxLength(200);
builder.Property(x => x.AvatarUrl)
.HasMaxLength(500);
// Many-to-Many relationship with Competencies
builder.HasMany(x => x.Competencies)
.WithMany()
.UsingEntity<Dictionary<string, object>>(
"UserProfileCompetencies",
j => j.HasOne<Competency>().WithMany().HasForeignKey("CompetencyId"),
j => j.HasOne<UserProfile>().WithMany().HasForeignKey("UserProfileId"),
j =>
{
j.ToTable("UserProfileCompetencies", "identity");
j.HasKey("UserProfileId", "CompetencyId");
});
// 1:1 relationship with Account
builder.HasOne<Account>()
.WithOne(x => x.Profile)
.HasForeignKey<UserProfile>(x => x.Id)
.OnDelete(DeleteBehavior.Cascade);
}
}
@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Nashel.Modules.Identity.Domain.Aggregates;
using Nashel.Modules.Identity.Domain.Entities;
using Nashel.Modules.Identity.Infrastructure.Persistence.Configurations;
namespace Nashel.Modules.Identity.Infrastructure.Persistence;
@@ -11,10 +12,14 @@ public class IdentityDbContext : DbContext
}
public DbSet<Account> Accounts { get; set; }
public DbSet<UserProfile> UserProfiles { get; set; }
public DbSet<Competency> Competencies { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new AccountConfiguration());
modelBuilder.ApplyConfiguration(new UserProfileConfiguration());
modelBuilder.ApplyConfiguration(new CompetencyConfiguration());
base.OnModelCreating(modelBuilder);
}
}
@@ -0,0 +1,104 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Nashel.Modules.Identity.Infrastructure.Persistence;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(IdentityDbContext))]
[Migration("20260213085826_AddUserProfile")]
partial class AddUserProfile
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.Account", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Phone")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Roles")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("Phone")
.IsUnique();
b.ToTable("Accounts", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("AvatarUrl")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<string>("CompanyName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("Patronymic")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.ToTable("UserProfiles", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
{
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.Account", null)
.WithOne("Profile")
.HasForeignKey("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.Account", b =>
{
b.Navigation("Profile")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddUserProfile : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "UserProfiles",
schema: "identity",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
FirstName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
LastName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Patronymic = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
CompanyName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
AvatarUrl = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserProfiles_Accounts_Id",
column: x => x.Id,
principalSchema: "identity",
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserProfiles",
schema: "identity");
}
}
}
@@ -0,0 +1,154 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Nashel.Modules.Identity.Infrastructure.Persistence;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(IdentityDbContext))]
[Migration("20260213103833_AddCompetencies")]
partial class AddCompetencies
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.Account", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Phone")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Roles")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("Phone")
.IsUnique();
b.ToTable("Accounts", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("AvatarUrl")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<string>("CompanyName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("Patronymic")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.ToTable("UserProfiles", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Entities.Competency", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_Competencies_Name");
b.ToTable("Competencies", "identity");
});
modelBuilder.Entity("UserProfileCompetencies", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompetencyId")
.HasColumnType("uuid");
b.HasKey("UserProfileId", "CompetencyId");
b.HasIndex("CompetencyId");
b.ToTable("UserProfileCompetencies", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
{
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.Account", null)
.WithOne("Profile")
.HasForeignKey("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("UserProfileCompetencies", b =>
{
b.HasOne("Nashel.Modules.Identity.Domain.Entities.Competency", null)
.WithMany()
.HasForeignKey("CompetencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", null)
.WithMany()
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.Account", b =>
{
b.Navigation("Profile")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,80 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddCompetencies : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Competencies",
schema: "identity",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Competencies", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserProfileCompetencies",
schema: "identity",
columns: table => new
{
UserProfileId = table.Column<Guid>(type: "uuid", nullable: false),
CompetencyId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserProfileCompetencies", x => new { x.UserProfileId, x.CompetencyId });
table.ForeignKey(
name: "FK_UserProfileCompetencies_Competencies_CompetencyId",
column: x => x.CompetencyId,
principalSchema: "identity",
principalTable: "Competencies",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserProfileCompetencies_UserProfiles_UserProfileId",
column: x => x.UserProfileId,
principalSchema: "identity",
principalTable: "UserProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Competencies_Name",
schema: "identity",
table: "Competencies",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserProfileCompetencies_CompetencyId",
schema: "identity",
table: "UserProfileCompetencies",
column: "CompetencyId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserProfileCompetencies",
schema: "identity");
migrationBuilder.DropTable(
name: "Competencies",
schema: "identity");
}
}
}
@@ -48,6 +48,103 @@ namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
b.ToTable("Accounts", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<string>("AvatarUrl")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<string>("CompanyName")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("Patronymic")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.ToTable("UserProfiles", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Entities.Competency", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique()
.HasDatabaseName("IX_Competencies_Name");
b.ToTable("Competencies", "identity");
});
modelBuilder.Entity("UserProfileCompetencies", b =>
{
b.Property<Guid>("UserProfileId")
.HasColumnType("uuid");
b.Property<Guid>("CompetencyId")
.HasColumnType("uuid");
b.HasKey("UserProfileId", "CompetencyId");
b.HasIndex("CompetencyId");
b.ToTable("UserProfileCompetencies", "identity");
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
{
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.Account", null)
.WithOne("Profile")
.HasForeignKey("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", "Id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("UserProfileCompetencies", b =>
{
b.HasOne("Nashel.Modules.Identity.Domain.Entities.Competency", null)
.WithMany()
.HasForeignKey("CompetencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", null)
.WithMany()
.HasForeignKey("UserProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.Account", b =>
{
b.Navigation("Profile")
.IsRequired();
});
#pragma warning restore 612, 618
}
}