Правка регистрации, расписание, смена ролей
This commit is contained in:
@@ -1,10 +1,20 @@
|
||||
using MediatR;
|
||||
using Nashel.BuildingBlocks.Application.Abstractions;
|
||||
using Nashel.Modules.Identity.Domain.Entities;
|
||||
using Nashel.Modules.Identity.Domain.Repositories;
|
||||
|
||||
namespace Nashel.Modules.Identity.Application.Commands;
|
||||
|
||||
public record BecomePerformerCommand : IRequest<Unit>;
|
||||
public record BecomePerformerCommand : IRequest<Unit>
|
||||
{
|
||||
public string Description { get; init; } = default!;
|
||||
public List<string> CompetencyNames { get; init; } = default!;
|
||||
public bool Is24_7 { get; init; }
|
||||
public bool IsAlwaysReady { get; init; }
|
||||
public List<string>? WorkingDays { get; init; }
|
||||
public string? WorkingHoursStart { get; init; }
|
||||
public string? WorkingHoursEnd { get; init; }
|
||||
}
|
||||
|
||||
public class BecomePerformerCommandHandler : IRequestHandler<BecomePerformerCommand, Unit>
|
||||
{
|
||||
@@ -25,13 +35,52 @@ public class BecomePerformerCommandHandler : IRequestHandler<BecomePerformerComm
|
||||
throw new Exception("Неавторизован");
|
||||
}
|
||||
|
||||
var account = await _accountRepository.GetByIdAsync(userId.Value, cancellationToken); // Need GetById in repo
|
||||
var account = await _accountRepository.GetByIdAsync(userId.Value, cancellationToken);
|
||||
if (account == null)
|
||||
{
|
||||
throw new Exception("Аккаунт не найден");
|
||||
}
|
||||
|
||||
// Создаем компетенции
|
||||
var competencies = request.CompetencyNames
|
||||
.Select(name => Competency.Create(name))
|
||||
.ToList();
|
||||
|
||||
// Создаем график работы
|
||||
WorkSchedule? workSchedule = null;
|
||||
if (request.Is24_7 || request.IsAlwaysReady || (request.WorkingDays != null && request.WorkingDays.Any()))
|
||||
{
|
||||
string? workingDaysJson = null;
|
||||
string? workingHoursJson = null;
|
||||
|
||||
if (request.WorkingDays != null && request.WorkingDays.Any())
|
||||
{
|
||||
workingDaysJson = System.Text.Json.JsonSerializer.Serialize(request.WorkingDays);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(request.WorkingHoursStart) && !string.IsNullOrEmpty(request.WorkingHoursEnd))
|
||||
{
|
||||
workingHoursJson = System.Text.Json.JsonSerializer.Serialize(new
|
||||
{
|
||||
start = request.WorkingHoursStart,
|
||||
end = request.WorkingHoursEnd
|
||||
});
|
||||
}
|
||||
|
||||
workSchedule = WorkSchedule.Create(
|
||||
request.Is24_7,
|
||||
request.IsAlwaysReady,
|
||||
workingDaysJson,
|
||||
workingHoursJson
|
||||
);
|
||||
}
|
||||
|
||||
// Обновляем данные исполнителя
|
||||
account.UpdatePerformerData(request.Description, competencies, workSchedule);
|
||||
|
||||
// Добавляем роль исполнителя
|
||||
account.BecomePerformer();
|
||||
|
||||
await _accountRepository.UpdateAsync(account, cancellationToken);
|
||||
|
||||
return Unit.Value;
|
||||
|
||||
@@ -6,6 +6,14 @@ namespace Nashel.Modules.Identity.Application.Queries.GetProfile;
|
||||
|
||||
public record GetProfileQuery : IRequest<ProfileResponse>;
|
||||
|
||||
public record WorkScheduleResponse(
|
||||
bool Is24_7,
|
||||
bool IsAlwaysReady,
|
||||
List<string>? WorkingDays,
|
||||
string? WorkingHoursStart,
|
||||
string? WorkingHoursEnd
|
||||
);
|
||||
|
||||
public record ProfileResponse(
|
||||
Guid Id,
|
||||
string Phone,
|
||||
@@ -18,7 +26,8 @@ public record ProfileResponse(
|
||||
string? Description,
|
||||
string FullName,
|
||||
string? AvatarUrl,
|
||||
List<string> Competencies);
|
||||
List<string> Competencies,
|
||||
WorkScheduleResponse? WorkSchedule);
|
||||
|
||||
public class GetProfileQueryHandler : IRequestHandler<GetProfileQuery, ProfileResponse>
|
||||
{
|
||||
@@ -51,6 +60,38 @@ public class GetProfileQueryHandler : IRequestHandler<GetProfileQuery, ProfileRe
|
||||
fullName += $" {account.Profile.Patronymic}";
|
||||
}
|
||||
|
||||
// Парсинг WorkSchedule
|
||||
WorkScheduleResponse? workScheduleResponse = null;
|
||||
if (account.Profile.WorkSchedule != null)
|
||||
{
|
||||
var workingDays = account.Profile.WorkSchedule.WorkingDays != null
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<string>>(account.Profile.WorkSchedule.WorkingDays)
|
||||
: null;
|
||||
|
||||
string? workingHoursStart = null;
|
||||
string? workingHoursEnd = null;
|
||||
if (account.Profile.WorkSchedule.WorkingHours != null)
|
||||
{
|
||||
var workingHours = System.Text.Json.JsonSerializer.Deserialize<System.Text.Json.JsonElement>(account.Profile.WorkSchedule.WorkingHours);
|
||||
if (workingHours.TryGetProperty("start", out var start))
|
||||
{
|
||||
workingHoursStart = start.GetString();
|
||||
}
|
||||
if (workingHours.TryGetProperty("end", out var end))
|
||||
{
|
||||
workingHoursEnd = end.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
workScheduleResponse = new WorkScheduleResponse(
|
||||
account.Profile.WorkSchedule.Is24_7,
|
||||
account.Profile.WorkSchedule.IsAlwaysReady,
|
||||
workingDays,
|
||||
workingHoursStart,
|
||||
workingHoursEnd
|
||||
);
|
||||
}
|
||||
|
||||
return new ProfileResponse(
|
||||
account.Id,
|
||||
account.Phone,
|
||||
@@ -63,6 +104,7 @@ public class GetProfileQueryHandler : IRequestHandler<GetProfileQuery, ProfileRe
|
||||
account.Profile.Description,
|
||||
fullName,
|
||||
account.Profile.AvatarUrl,
|
||||
account.Profile.Competencies.Select(c => c.Name).ToList());
|
||||
account.Profile.Competencies.Select(c => c.Name).ToList(),
|
||||
workScheduleResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Nashel.BuildingBlocks.Domain;
|
||||
using Nashel.Modules.Identity.Domain.Entities;
|
||||
using Nashel.Modules.Identity.Domain.Enums;
|
||||
using Nashel.Modules.Identity.Domain.Events;
|
||||
|
||||
@@ -40,17 +41,17 @@ public class Account : AggregateRoot<Guid>
|
||||
|
||||
public void BecomePerformer()
|
||||
{
|
||||
if (!Roles.Contains(Role.Candidate) && !Roles.Contains(Role.Master))
|
||||
if (!Roles.Contains(Role.Newbie) && !Roles.Contains(Role.Master))
|
||||
{
|
||||
Roles.Add(Role.Candidate);
|
||||
Roles.Add(Role.Newbie);
|
||||
}
|
||||
}
|
||||
|
||||
public void PromoteToMaster()
|
||||
{
|
||||
if (Roles.Contains(Role.Candidate))
|
||||
if (Roles.Contains(Role.Newbie))
|
||||
{
|
||||
Roles.Remove(Role.Candidate);
|
||||
Roles.Remove(Role.Newbie);
|
||||
}
|
||||
|
||||
if (!Roles.Contains(Role.Master))
|
||||
@@ -58,4 +59,19 @@ public class Account : AggregateRoot<Guid>
|
||||
Roles.Add(Role.Master);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePerformerData(string description, IEnumerable<Competency> competencies, WorkSchedule? workSchedule)
|
||||
{
|
||||
Profile.UpdatePerformerData(description, competencies, workSchedule);
|
||||
}
|
||||
|
||||
public void UpdateWorkSchedule(WorkSchedule workSchedule)
|
||||
{
|
||||
Profile.SetWorkSchedule(workSchedule);
|
||||
}
|
||||
|
||||
public bool IsPerformer()
|
||||
{
|
||||
return Roles.Contains(Role.Newbie) || Roles.Contains(Role.Master);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class UserProfile : Entity<Guid>
|
||||
public string? Description { get; private set; }
|
||||
public string? AvatarUrl { get; private set; }
|
||||
public IReadOnlyCollection<Competency> Competencies => _competencies.AsReadOnly();
|
||||
public WorkSchedule? WorkSchedule { get; private set; }
|
||||
|
||||
// EF Core constructor
|
||||
private UserProfile() { }
|
||||
@@ -68,4 +69,29 @@ public class UserProfile : Entity<Guid>
|
||||
_competencies.Clear();
|
||||
_competencies.AddRange(competencyList);
|
||||
}
|
||||
|
||||
public void UpdatePerformerData(string description, IEnumerable<Competency> competencies, WorkSchedule? workSchedule)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(description) || description.Length < 50)
|
||||
throw new ArgumentException($"Описание должно содержать минимум 50 символов", nameof(description));
|
||||
|
||||
if (description.Length > MaxDescriptionLength)
|
||||
throw new ArgumentException($"Описание не может превышать {MaxDescriptionLength} символов", nameof(description));
|
||||
|
||||
Description = description;
|
||||
|
||||
var competencyList = competencies.ToList();
|
||||
if (competencyList.Count > MaxCompetencies)
|
||||
throw new InvalidOperationException($"Нельзя добавить больше {MaxCompetencies} компетенций");
|
||||
|
||||
_competencies.Clear();
|
||||
_competencies.AddRange(competencyList);
|
||||
|
||||
WorkSchedule = workSchedule;
|
||||
}
|
||||
|
||||
public void SetWorkSchedule(WorkSchedule workSchedule)
|
||||
{
|
||||
WorkSchedule = workSchedule;
|
||||
}
|
||||
}
|
||||
|
||||
49
src/Modules/Identity/Domain/Entities/WorkSchedule.cs
Normal file
49
src/Modules/Identity/Domain/Entities/WorkSchedule.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace Nashel.Modules.Identity.Domain.Entities;
|
||||
|
||||
public class WorkSchedule
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public bool Is24_7 { get; private set; }
|
||||
public bool IsAlwaysReady { get; private set; }
|
||||
public string? WorkingDays { get; private set; } // JSON-массив дней недели: ["Mon", "Tue", ...]
|
||||
public string? WorkingHours { get; private set; } // JSON: {"start": "09:00", "end": "18:00"}
|
||||
|
||||
// EF Core constructor
|
||||
private WorkSchedule() { }
|
||||
|
||||
private WorkSchedule(bool is24_7, bool isAlwaysReady, string? workingDays, string? workingHours)
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
Is24_7 = is24_7;
|
||||
IsAlwaysReady = isAlwaysReady;
|
||||
WorkingDays = workingDays;
|
||||
WorkingHours = workingHours;
|
||||
}
|
||||
|
||||
public static WorkSchedule Create(bool is24_7, bool isAlwaysReady, string? workingDays, string? workingHours)
|
||||
{
|
||||
// Если 24/7 или Always Ready, то дни и часы не нужны
|
||||
if (is24_7 || isAlwaysReady)
|
||||
{
|
||||
workingDays = null;
|
||||
workingHours = null;
|
||||
}
|
||||
|
||||
return new WorkSchedule(is24_7, isAlwaysReady, workingDays, workingHours);
|
||||
}
|
||||
|
||||
public void Update(bool is24_7, bool isAlwaysReady, string? workingDays, string? workingHours)
|
||||
{
|
||||
// Если 24/7 или Always Ready, то дни и часы не нужны
|
||||
if (is24_7 || isAlwaysReady)
|
||||
{
|
||||
workingDays = null;
|
||||
workingHours = null;
|
||||
}
|
||||
|
||||
Is24_7 = is24_7;
|
||||
IsAlwaysReady = isAlwaysReady;
|
||||
WorkingDays = workingDays;
|
||||
WorkingHours = workingHours;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Nashel.Modules.Identity.Domain.Enums;
|
||||
public enum Role
|
||||
{
|
||||
User = 0,
|
||||
Candidate,
|
||||
Newbie,
|
||||
Master,
|
||||
Company,
|
||||
Admin
|
||||
|
||||
@@ -37,6 +37,12 @@ public class UserProfileConfiguration : IEntityTypeConfiguration<UserProfile>
|
||||
builder.Property(x => x.AvatarUrl)
|
||||
.HasMaxLength(500);
|
||||
|
||||
// Optional 1:1 relationship with WorkSchedule
|
||||
builder.HasOne(x => x.WorkSchedule)
|
||||
.WithOne()
|
||||
.HasForeignKey<WorkSchedule>(x => x.Id)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// Many-to-Many relationship with Competencies
|
||||
builder.HasMany(x => x.Competencies)
|
||||
.WithMany()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Nashel.Modules.Identity.Domain.Entities;
|
||||
|
||||
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Configurations;
|
||||
|
||||
public class WorkScheduleConfiguration : IEntityTypeConfiguration<WorkSchedule>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<WorkSchedule> builder)
|
||||
{
|
||||
builder.ToTable("WorkSchedules", "identity");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
|
||||
builder.Property(x => x.Is24_7)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsAlwaysReady)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.WorkingDays)
|
||||
.HasMaxLength(100); // JSON-массив дней недели
|
||||
|
||||
builder.Property(x => x.WorkingHours)
|
||||
.HasMaxLength(100); // JSON с часами работы
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,14 @@ public class IdentityDbContext : DbContext
|
||||
public DbSet<Account> Accounts { get; set; }
|
||||
public DbSet<UserProfile> UserProfiles { get; set; }
|
||||
public DbSet<Competency> Competencies { get; set; }
|
||||
public DbSet<WorkSchedule> WorkSchedules { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfiguration(new AccountConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new UserProfileConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new CompetencyConfiguration());
|
||||
modelBuilder.ApplyConfiguration(new WorkScheduleConfiguration());
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
// <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("20260216085438_AddWorkScheduleToUserProfile")]
|
||||
partial class AddWorkScheduleToUserProfile
|
||||
{
|
||||
/// <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>("Description")
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("character varying(2048)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<string>("Inn")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
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("Nashel.Modules.Identity.Domain.Entities.WorkSchedule", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("Is24_7")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsAlwaysReady")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("WorkingDays")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<string>("WorkingHours")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WorkSchedules", "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("Nashel.Modules.Identity.Domain.Entities.WorkSchedule", b =>
|
||||
{
|
||||
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", null)
|
||||
.WithOne("WorkSchedule")
|
||||
.HasForeignKey("Nashel.Modules.Identity.Domain.Entities.WorkSchedule", "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();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
|
||||
{
|
||||
b.Navigation("WorkSchedule");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddWorkScheduleToUserProfile : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WorkSchedules",
|
||||
schema: "identity",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Is24_7 = table.Column<bool>(type: "boolean", nullable: false),
|
||||
IsAlwaysReady = table.Column<bool>(type: "boolean", nullable: false),
|
||||
WorkingDays = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
||||
WorkingHours = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WorkSchedules", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_WorkSchedules_UserProfiles_Id",
|
||||
column: x => x.Id,
|
||||
principalSchema: "identity",
|
||||
principalTable: "UserProfiles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "WorkSchedules",
|
||||
schema: "identity");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,30 @@ namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
|
||||
b.ToTable("Competencies", "identity");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Entities.WorkSchedule", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("Is24_7")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsAlwaysReady")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("WorkingDays")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<string>("WorkingHours")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WorkSchedules", "identity");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UserProfileCompetencies", b =>
|
||||
{
|
||||
b.Property<Guid>("UserProfileId")
|
||||
@@ -133,6 +157,15 @@ namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Entities.WorkSchedule", b =>
|
||||
{
|
||||
b.HasOne("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", null)
|
||||
.WithOne("WorkSchedule")
|
||||
.HasForeignKey("Nashel.Modules.Identity.Domain.Entities.WorkSchedule", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UserProfileCompetencies", b =>
|
||||
{
|
||||
b.HasOne("Nashel.Modules.Identity.Domain.Entities.Competency", null)
|
||||
@@ -153,6 +186,11 @@ namespace Nashel.Modules.Identity.Infrastructure.Persistence.Migrations
|
||||
b.Navigation("Profile")
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Nashel.Modules.Identity.Domain.Aggregates.UserProfile", b =>
|
||||
{
|
||||
b.Navigation("WorkSchedule");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +56,18 @@ public static class IdentityEndpoints
|
||||
.WithName("ChangePhone")
|
||||
.WithOpenApi(operation => new(operation) { Summary = "Сменить номер телефона" });
|
||||
|
||||
profileGroup.MapPost("/become-performer", async (ISender sender) =>
|
||||
profileGroup.MapPost("/become-performer", async (BecomePerformerRequest request, ISender sender) =>
|
||||
{
|
||||
await sender.Send(new BecomePerformerCommand());
|
||||
await sender.Send(new BecomePerformerCommand
|
||||
{
|
||||
Description = request.Description,
|
||||
CompetencyNames = request.Competencies,
|
||||
Is24_7 = request.Is24_7,
|
||||
IsAlwaysReady = request.IsAlwaysReady,
|
||||
WorkingDays = request.WorkingDays,
|
||||
WorkingHoursStart = request.WorkingHoursStart,
|
||||
WorkingHoursEnd = request.WorkingHoursEnd
|
||||
});
|
||||
return Results.Ok();
|
||||
})
|
||||
.WithName("BecomePerformer")
|
||||
@@ -95,3 +104,12 @@ public static class IdentityEndpoints
|
||||
|
||||
public record LoginResponse(string AccessToken, string RefreshToken);
|
||||
public record UpdateCompetenciesRequest(List<string> Competencies);
|
||||
public record BecomePerformerRequest(
|
||||
string Description,
|
||||
List<string> Competencies,
|
||||
bool Is24_7,
|
||||
bool IsAlwaysReady,
|
||||
List<string>? WorkingDays,
|
||||
string? WorkingHoursStart,
|
||||
string? WorkingHoursEnd
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user