2 часть

This commit is contained in:
bekodeg
2025-06-08 23:24:45 +04:00
parent d5d2427432
commit ef5f23f3a5
19 changed files with 988 additions and 6 deletions

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,23 @@
using ApplicationSystem.MediatRHelper.Models;
using System.ComponentModel.DataAnnotations;
namespace ApplicationSystem.Contracts.Models.UserRequests
{
/// <summary>
/// Запрос на вход
/// </summary>
public record LoginRequest
{
/// <summary>
/// Логин пользователя
/// </summary>
[Required(AllowEmptyStrings = false)]
public string Email { get; init; } = null!;
/// <summary>
/// Пароль пользователя
/// </summary>
[Required(AllowEmptyStrings = false)]
public string Password { get; init; } = null!;
}
}

View File

@@ -0,0 +1,6 @@
namespace ApplicationSystem.Contracts.Models.UserRequests
{
public class LogoutRequest
{
}
}

View File

@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
namespace ApplicationSystem.Contracts.Models.UserRequests
{
public class RegisterRequest
{
/// <summary>
/// Логин пользователя
/// </summary>
[Required(AllowEmptyStrings = false)]
public string Email { get; init; } = null!;
/// <summary>
/// Пароль пользователя
/// </summary>
[Required(AllowEmptyStrings = false)]
public string Password { get; init; } = null!;
/// <summary>
/// Имя пользователя
/// </summary>
[Required(AllowEmptyStrings = false)]
public string UserName { get; init; } = null!;
}
}

View File

@@ -7,10 +7,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.16">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.16">
<PrivateAssets>all</PrivateAssets>

View File

@@ -15,6 +15,10 @@ namespace ApplicationSystem.Identity.Database.Context
IdentityRoleClaim<Guid>,
IdentityUserToken<Guid>>
{
public IdentityContext(DbContextOptions<IdentityContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);

View File

@@ -0,0 +1,279 @@
// <auto-generated />
using System;
using ApplicationSystem.Identity.Database.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ApplicationSystem.Identity.Database.Migrations
{
[DbContext(typeof(IdentityContext))]
[Migration("20250608181053_InitDatabase")]
partial class InitDatabase
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("identity")
.HasAnnotation("ProductVersion", "8.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ApplicationSystem.Identity.Database.Models.ApplicationSystemRole", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("role", "identity");
});
modelBuilder.Entity("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("user", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("role_claim", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("user_claim", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(450)");
b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(450)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("user_login", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("user_role", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(450)");
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("user_token", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,254 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ApplicationSystem.Identity.Database.Migrations
{
/// <inheritdoc />
public partial class InitDatabase : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "identity");
migrationBuilder.CreateTable(
name: "role",
schema: "identity",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_role", x => x.Id);
});
migrationBuilder.CreateTable(
name: "user",
schema: "identity",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false),
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
SecurityStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user", x => x.Id);
});
migrationBuilder.CreateTable(
name: "role_claim",
schema: "identity",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_role_claim", x => x.Id);
table.ForeignKey(
name: "FK_role_claim_role_RoleId",
column: x => x.RoleId,
principalSchema: "identity",
principalTable: "role",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "user_claim",
schema: "identity",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_user_claim", x => x.Id);
table.ForeignKey(
name: "FK_user_claim_user_UserId",
column: x => x.UserId,
principalSchema: "identity",
principalTable: "user",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "user_login",
schema: "identity",
columns: table => new
{
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
ProviderKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user_login", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_user_login_user_UserId",
column: x => x.UserId,
principalSchema: "identity",
principalTable: "user",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "user_role",
schema: "identity",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RoleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user_role", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_user_role_role_RoleId",
column: x => x.RoleId,
principalSchema: "identity",
principalTable: "role",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_user_role_user_UserId",
column: x => x.UserId,
principalSchema: "identity",
principalTable: "user",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "user_token",
schema: "identity",
columns: table => new
{
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_user_token", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_user_token_user_UserId",
column: x => x.UserId,
principalSchema: "identity",
principalTable: "user",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
schema: "identity",
table: "role",
column: "NormalizedName",
unique: true,
filter: "[NormalizedName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_role_claim_RoleId",
schema: "identity",
table: "role_claim",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
schema: "identity",
table: "user",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
schema: "identity",
table: "user",
column: "NormalizedUserName",
unique: true,
filter: "[NormalizedUserName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_user_claim_UserId",
schema: "identity",
table: "user_claim",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_user_login_UserId",
schema: "identity",
table: "user_login",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_user_role_RoleId",
schema: "identity",
table: "user_role",
column: "RoleId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "role_claim",
schema: "identity");
migrationBuilder.DropTable(
name: "user_claim",
schema: "identity");
migrationBuilder.DropTable(
name: "user_login",
schema: "identity");
migrationBuilder.DropTable(
name: "user_role",
schema: "identity");
migrationBuilder.DropTable(
name: "user_token",
schema: "identity");
migrationBuilder.DropTable(
name: "role",
schema: "identity");
migrationBuilder.DropTable(
name: "user",
schema: "identity");
}
}
}

View File

@@ -0,0 +1,276 @@
// <auto-generated />
using System;
using ApplicationSystem.Identity.Database.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ApplicationSystem.Identity.Database.Migrations
{
[DbContext(typeof(IdentityContext))]
partial class IdentityContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("identity")
.HasAnnotation("ProductVersion", "8.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ApplicationSystem.Identity.Database.Models.ApplicationSystemRole", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("role", "identity");
});
modelBuilder.Entity("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("user", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("role_claim", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("user_claim", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(450)");
b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(450)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("user_login", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("user_role", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(450)");
b.Property<string>("Name")
.HasColumnType("nvarchar(450)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("user_token", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.HasOne("ApplicationSystem.Identity.Database.Models.ApplicationSystemUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="8.1.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,11 @@
using MediatR;
namespace ApplicationSystem.MediatRHelper.Models
{
/// <summary>
/// Запрос к медиатору
/// </summary>
public interface IRequestModel<TResponse> : IRequest<TResponse>
{
}
}

View File

@@ -0,0 +1,11 @@
using MediatR;
namespace ApplicationSystem.MediatRHelper.Models
{
/// <summary>
/// Запрос к медиатору без параметров
/// </summary>
public interface IRequestModelWP : IRequest<ResponseModel>
{
}
}

View File

@@ -0,0 +1,13 @@
namespace ApplicationSystem.MediatRHelper.Models
{
/// <summary>
/// Модель результата выполнения запроса с возвращаемым значением
/// </summary>
public class ResponseModel<TResponse> : ResponseModel
{
/// <summary>
/// Результат успешного выполнения запроса
/// </summary>
public TResponse? Response { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System.Net;
namespace ApplicationSystem.MediatRHelper.Models
{
/// <summary>
/// Модель результата выполнения запроса
/// </summary>
public class ResponseModel
{
/// <summary>
/// Код результата обработки запроса
/// </summary>
public HttpStatusCode ResponseStatusCode;
}
}

View File

@@ -9,7 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationSystem.Database"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationSystem.Identity", "ApplicationSystem.Identity\ApplicationSystem.Identity.csproj", "{73E95BBE-82B6-4DD6-BA95-BC3A52E79394}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationSystem.Configurations", "ApplicationSystem.Configurations\ApplicationSystem.Configurations.csproj", "{F8BF79B4-B8C9-4A31-A9C7-4C1AB4C66E76}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationSystem.Configurations", "ApplicationSystem.Configurations\ApplicationSystem.Configurations.csproj", "{F8BF79B4-B8C9-4A31-A9C7-4C1AB4C66E76}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationSystem.Contracts", "ApplicationSystem.Contracts\ApplicationSystem.Contracts.csproj", "{353055EF-FE25-4DA2-9B6F-A6E8757C18A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationSystem.MediatRHelper", "ApplicationSystem.MediatrHelper\ApplicationSystem.MediatRHelper.csproj", "{13F17CD8-F011-4C5F-9052-674E9CA73C81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,6 +37,14 @@ Global
{F8BF79B4-B8C9-4A31-A9C7-4C1AB4C66E76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8BF79B4-B8C9-4A31-A9C7-4C1AB4C66E76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8BF79B4-B8C9-4A31-A9C7-4C1AB4C66E76}.Release|Any CPU.Build.0 = Release|Any CPU
{353055EF-FE25-4DA2-9B6F-A6E8757C18A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{353055EF-FE25-4DA2-9B6F-A6E8757C18A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{353055EF-FE25-4DA2-9B6F-A6E8757C18A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{353055EF-FE25-4DA2-9B6F-A6E8757C18A1}.Release|Any CPU.Build.0 = Release|Any CPU
{13F17CD8-F011-4C5F-9052-674E9CA73C81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13F17CD8-F011-4C5F-9052-674E9CA73C81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13F17CD8-F011-4C5F-9052-674E9CA73C81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13F17CD8-F011-4C5F-9052-674E9CA73C81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -9,10 +9,16 @@
<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="MediatR" Version="8.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.16">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApplicationSystem.Identity\ApplicationSystem.Identity.csproj" />
<ProjectReference Include="..\ApplicationSystem.MediatrHelper\ApplicationSystem.MediatRHelper.csproj" />
</ItemGroup>
</Project>

View File

@@ -6,7 +6,7 @@ namespace ApplicationSystem.Controllers
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class ApplicationController : ControllerBase
public class ApplicationsController : ControllerBase
{
[HttpPost]
public async Task<IActionResult> CreateApplicationAsync()

View File

@@ -0,0 +1,18 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
namespace ApplicationSystem.Controllers
{
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class UsersController : ControllerBase
{
[HttpPost("login")]
public async Task<IActionResult> LoginAsync()
{
await Task.Delay(100);
return Ok();
}
}
}

View File

@@ -0,0 +1,11 @@
using ApplicationSystem.MediatRHelper.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.Data;
namespace ApplicationSystem.Models.Queries
{
public record LoginQuery : IRequestModel<SignInResult>
{
public LoginRequest LoginRequest { get; init; } = null!;
}
}