Зависимости на контракты
This commit is contained in:
@@ -1,22 +1,19 @@
|
||||
using Carter;
|
||||
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
||||
using Knot.Shared.Kernel;
|
||||
using Knot.Contracts.Settings.Application.Abstractions;
|
||||
using Knot.Contracts.Settings.Application.DTOs;
|
||||
using Knot.Modules.Auth.Application.Users.Register;
|
||||
using MediatR;
|
||||
using Knot.Modules.Admin.Application.Admin.Queries;
|
||||
using Knot.Modules.Admin.Application.Admin.Commands;
|
||||
using Knot.Modules.Admin.Application.Admin.Commands.TestKlipy;
|
||||
using Knot.Modules.Admin.Application.Admin.Queries;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Knot.Modules.Admin.Application.Admin.Commands.TestKlipy;
|
||||
using Knot.Modules.Conversations.Application.Users.Commands.DeleteUser;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
||||
namespace Knot.Host.Presentation.Endpoints;
|
||||
|
||||
public record KlipyTestDto(string ApiKey, string AppName);
|
||||
public record ResetPasswordRequest(string NewPassword);
|
||||
|
||||
public sealed class AdminEndpoints : ICarterModule
|
||||
{
|
||||
@@ -47,20 +44,11 @@ public sealed class AdminEndpoints : ICarterModule
|
||||
var result = await sender.Send(new GetDashboardStatsQuery(), ct);
|
||||
return Results.Ok(result.Value);
|
||||
});
|
||||
|
||||
group.MapPost("users", async ([FromBody] RegisterUserCommand command, ISender sender, CancellationToken ct) =>
|
||||
{
|
||||
var result = await sender.Send(command, ct);
|
||||
if (result.IsFailure) return Results.BadRequest(new { error = result.Error.Description });
|
||||
|
||||
var userDetails = await sender.Send(new GetUserDetailsQuery(result.Value.UserId), ct);
|
||||
return Results.Ok(userDetails.Value);
|
||||
});
|
||||
|
||||
group.MapPost("users/{userId:guid}/reset-password", async (Guid userId, [FromBody] ResetPasswordDto dto, ISender sender, CancellationToken ct) =>
|
||||
group.MapPost("users/{userId:guid}/reset-password", async (Guid userId, [FromBody] ResetPasswordRequest dto, ISender sender, CancellationToken ct) =>
|
||||
{
|
||||
var result = await sender.Send(new ResetUserPasswordCommand(userId, dto.NewPassword), ct);
|
||||
if (result.IsFailure)
|
||||
if (result.IsFailure)
|
||||
{
|
||||
if (result.Error.Code == "User.NotFound") return Results.NotFound(new { error = "User not found" });
|
||||
return Results.BadRequest(new { error = result.Error.Description });
|
||||
@@ -80,12 +68,6 @@ public sealed class AdminEndpoints : ICarterModule
|
||||
return result.IsSuccess ? Results.Ok() : Results.BadRequest(new { error = result.Error.Description });
|
||||
});
|
||||
|
||||
group.MapDelete("users/{userId:guid}", async (Guid userId, ISender sender, CancellationToken ct) =>
|
||||
{
|
||||
var result = await sender.Send(new DeleteUserCommand(userId), ct);
|
||||
return result.IsSuccess ? Results.Ok() : Results.BadRequest(new { error = result.Error.Description });
|
||||
});
|
||||
|
||||
group.MapGet("users", async (ISender sender, [FromQuery] string query = "", CancellationToken ct = default) =>
|
||||
{
|
||||
var result = await sender.Send(new SearchUsersQuery(query), ct);
|
||||
@@ -117,7 +99,8 @@ public sealed class AdminEndpoints : ICarterModule
|
||||
{
|
||||
// Получаем все системные часовые пояса и формируем удобный для фронтенда формат
|
||||
var zones = TimeZoneInfo.GetSystemTimeZones()
|
||||
.Select(tz => new {
|
||||
.Select(tz => new
|
||||
{
|
||||
id = tz.Id,
|
||||
displayName = tz.DisplayName,
|
||||
standardName = tz.StandardName,
|
||||
|
||||
Reference in New Issue
Block a user