implement

This commit is contained in:
2026-02-17 00:48:28 +01:00
parent 0119c7a737
commit 5c7909034f
57 changed files with 1676 additions and 114 deletions

View File

@@ -20,6 +20,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Application\Models\Shape\Command\DeleteShape\" />
<Folder Include="Domain\Models\WhiteboardMembership\Validation\" />
<Folder Include="Infrastructure\Persistence\Db\Migrations\" />
</ItemGroup>

View File

@@ -0,0 +1,6 @@
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Models.Shape.Command.CreateArrow;
namespace AipsCore.Application.Common.Message.AddArrow;
public record AddArrowMessage(CreateArrowCommand Command) : IMessage;

View File

@@ -0,0 +1,19 @@
using AipsCore.Application.Abstract;
using AipsCore.Application.Abstract.MessageBroking;
namespace AipsCore.Application.Common.Message.AddArrow;
public class AddArrowMessageHandler : IMessageHandler<AddArrowMessage>
{
private readonly IDispatcher _dispatcher;
public AddArrowMessageHandler(IDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public async Task Handle(AddArrowMessage message, CancellationToken cancellationToken)
{
await _dispatcher.Execute(message.Command, cancellationToken);
}
}

View File

@@ -0,0 +1,6 @@
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Models.Shape.Command.CreateLine;
namespace AipsCore.Application.Common.Message.AddLine;
public record AddLineMessage(CreateLineCommand Command) : IMessage;

View File

@@ -0,0 +1,20 @@
using AipsCore.Application.Abstract;
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Models.Shape.Command.CreateLine;
namespace AipsCore.Application.Common.Message.AddLine;
public class AddLineMessageHandler : IMessageHandler<AddLineMessage>
{
private readonly IDispatcher _dispatcher;
public AddLineMessageHandler(IDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public async Task Handle(AddLineMessage message, CancellationToken cancellationToken)
{
await _dispatcher.Execute(message.Command, cancellationToken);
}
}

View File

@@ -0,0 +1,6 @@
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Models.Shape.Command.CreateTextShape;
namespace AipsCore.Application.Common.Message.AddTextShape;
public record AddTextShapeMessage(CreateTextShapeCommand Command) : IMessage;

View File

@@ -0,0 +1,19 @@
using AipsCore.Application.Abstract;
using AipsCore.Application.Abstract.MessageBroking;
namespace AipsCore.Application.Common.Message.AddTextShape;
public class AddTextShapeMessageHandler : IMessageHandler<AddTextShapeMessage>
{
private readonly IDispatcher _dispatcher;
public AddTextShapeMessageHandler(IDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public async Task Handle(AddTextShapeMessage message, CancellationToken cancellationToken)
{
await _dispatcher.Execute(message.Command, cancellationToken);
}
}

View File

@@ -0,0 +1,6 @@
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Models.Shape.Command.MoveShape;
namespace AipsCore.Application.Common.Message.MoveShape;
public record MoveShapeMessage(MoveShapeCommand Command) : IMessage;

View File

@@ -0,0 +1,19 @@
using AipsCore.Application.Abstract;
using AipsCore.Application.Abstract.MessageBroking;
namespace AipsCore.Application.Common.Message.MoveShape;
public class MoveShapeMessageHandler : IMessageHandler<MoveShapeMessage>
{
private readonly IDispatcher _dispatcher;
public MoveShapeMessageHandler(IDispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public async Task Handle(MoveShapeMessage message, CancellationToken cancellationToken)
{
await _dispatcher.Execute(message.Command, cancellationToken);
}
}

View File

@@ -4,6 +4,7 @@ using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.CreateArrow;
public record CreateArrowCommand(
string Id,
string WhiteboardId,
string AuthorId,
int PositionX,
@@ -11,4 +12,4 @@ public record CreateArrowCommand(
string Color,
int EndPositionX,
int EndPositionY,
int Thickness) : ICommand<ShapeId>;
int Thickness) : ICommand;

View File

@@ -5,7 +5,7 @@ using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.CreateArrow;
public class CreateArrowCommandHandler : ICommandHandler<CreateArrowCommand, ShapeId>
public class CreateArrowCommandHandler : ICommandHandler<CreateArrowCommand>
{
private readonly IShapeRepository _shapeRepository;
private readonly IUnitOfWork _unitOfWork;
@@ -16,9 +16,10 @@ public class CreateArrowCommandHandler : ICommandHandler<CreateArrowCommand, Sha
_unitOfWork = unitOfWork;
}
public async Task<ShapeId> Handle(CreateArrowCommand command, CancellationToken cancellationToken = default)
public async Task Handle(CreateArrowCommand command, CancellationToken cancellationToken = default)
{
var arrow = Domain.Models.Shape.Sub.Arrow.Arrow.Create(
command.Id,
command.WhiteboardId,
command.AuthorId,
command.PositionX, command.PositionY,
@@ -28,8 +29,6 @@ public class CreateArrowCommandHandler : ICommandHandler<CreateArrowCommand, Sha
command.Thickness);
await _shapeRepository.SaveAsync(arrow, cancellationToken);
await _unitOfWork.SaveChangesAsync(cancellationToken);
return arrow.Id;
await _unitOfWork.SaveChangesAsync(cancellationToken);
}
}

View File

@@ -4,6 +4,7 @@ using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.CreateLine;
public record CreateLineCommand(
string Id,
string WhiteboardId,
string AuthorId,
int PositionX,
@@ -11,4 +12,4 @@ public record CreateLineCommand(
string Color,
int EndPositionX,
int EndPositionY,
int Thickness) : ICommand<ShapeId>;
int Thickness) : ICommand;

View File

@@ -5,7 +5,7 @@ using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.CreateLine;
public class CreateLineCommandHandler : ICommandHandler<CreateLineCommand, ShapeId>
public class CreateLineCommandHandler : ICommandHandler<CreateLineCommand>
{
private readonly IShapeRepository _shapeRepository;
private readonly IUnitOfWork _unitOfWork;
@@ -16,9 +16,10 @@ public class CreateLineCommandHandler : ICommandHandler<CreateLineCommand, Shape
_unitOfWork = unitOfWork;
}
public async Task<ShapeId> Handle(CreateLineCommand command, CancellationToken cancellationToken = default)
public async Task Handle(CreateLineCommand command, CancellationToken cancellationToken = default)
{
var line = Domain.Models.Shape.Sub.Line.Line.Create(
command.Id,
command.WhiteboardId,
command.AuthorId,
command.PositionX,
@@ -30,7 +31,5 @@ public class CreateLineCommandHandler : ICommandHandler<CreateLineCommand, Shape
await _shapeRepository.SaveAsync(line, cancellationToken);
await _unitOfWork.SaveChangesAsync(cancellationToken);
return line.Id;
}
}

View File

@@ -4,10 +4,11 @@ using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.CreateTextShape;
public record CreateTextShapeCommand(
string Id,
string WhiteboardId,
string AuthorId,
int PositionX,
int PositionY,
string Color,
string Text,
int TextSize) : ICommand<ShapeId>;
int TextSize) : ICommand;

View File

@@ -6,7 +6,7 @@ using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.CreateTextShape;
public class CreateTextShapeCommandHandler : ICommandHandler<CreateTextShapeCommand, ShapeId>
public class CreateTextShapeCommandHandler : ICommandHandler<CreateTextShapeCommand>
{
private readonly IShapeRepository _shapeRepository;
private readonly IUnitOfWork _unitOfWork;
@@ -17,9 +17,10 @@ public class CreateTextShapeCommandHandler : ICommandHandler<CreateTextShapeComm
_unitOfWork = unitOfWork;
}
public async Task<ShapeId> Handle(CreateTextShapeCommand command, CancellationToken cancellationToken = default)
public async Task Handle(CreateTextShapeCommand command, CancellationToken cancellationToken = default)
{
var textShape = TextShape.Create(
command.Id,
command.WhiteboardId,
command.AuthorId,
command.PositionX,
@@ -30,7 +31,5 @@ public class CreateTextShapeCommandHandler : ICommandHandler<CreateTextShapeComm
await _shapeRepository.SaveAsync(textShape, cancellationToken);
await _unitOfWork.SaveChangesAsync(cancellationToken);
return textShape.Id;
}
}

View File

@@ -0,0 +1,5 @@
using AipsCore.Application.Abstract.Command;
namespace AipsCore.Application.Models.Shape.Command.MoveShape;
public record MoveShapeCommand(string ShapeId, int NewPositionX, int NewPositionY) : ICommand;

View File

@@ -0,0 +1,36 @@
using AipsCore.Application.Abstract.Command;
using AipsCore.Domain.Abstract;
using AipsCore.Domain.Common.Validation;
using AipsCore.Domain.Models.Shape.External;
using AipsCore.Domain.Models.Shape.Validation;
using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Application.Models.Shape.Command.MoveShape;
public class MoveShapeCommandHandler : ICommandHandler<MoveShapeCommand>
{
private readonly IShapeRepository _shapeRepository;
private readonly IUnitOfWork _unitOfWork;
public MoveShapeCommandHandler(IShapeRepository shapeRepository, IUnitOfWork unitOfWork)
{
_shapeRepository = shapeRepository;
_unitOfWork = unitOfWork;
}
public async Task Handle(MoveShapeCommand command, CancellationToken cancellationToken = default)
{
var id = new ShapeId(command.ShapeId);
var shape = await _shapeRepository.GetByIdAsync(id, cancellationToken);
if (shape == null)
{
throw new ValidationException(ShapeErrors.NotFound(id));
}
shape.Move(command.NewPositionX, command.NewPositionY);
await _shapeRepository.SaveAsync(shape, cancellationToken);
await _unitOfWork.SaveChangesAsync(cancellationToken);
}
}

View File

@@ -0,0 +1,13 @@
using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Domain.Models.Shape;
public partial class Shape
{
public virtual void Move(int newPositionX, int newPositionY)
{
var newPosition = new Position(newPositionX, newPositionY);
this.Position = newPosition;
}
}

View File

@@ -7,7 +7,7 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
namespace AipsCore.Domain.Models.Shape;
public abstract class Shape : DomainModel<ShapeId>
public abstract partial class Shape : DomainModel<ShapeId>
{
public WhiteboardId WhiteboardId { get; private set; }

View File

@@ -0,0 +1,11 @@
namespace AipsCore.Domain.Models.Shape.Sub.Arrow;
public partial class Arrow
{
public override void Move(int newPositionX, int newPositionY)
{
EndPosition.X += newPositionX - Position.X;
EndPosition.Y += newPositionY - Position.Y;
base.Move(newPositionX, newPositionY);
}
}

View File

@@ -6,7 +6,7 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
namespace AipsCore.Domain.Models.Shape.Sub.Arrow;
public class Arrow : Shape
public partial class Arrow : Shape
{
public Position EndPosition { get; private set; }
public Thickness Thickness { get; private set; }

View File

@@ -0,0 +1,11 @@
namespace AipsCore.Domain.Models.Shape.Sub.Line;
public partial class Line
{
public override void Move(int newPositionX, int newPositionY)
{
EndPosition.X += newPositionX - Position.X;
EndPosition.Y += newPositionY - Position.Y;
base.Move(newPositionX, newPositionY);
}
}

View File

@@ -6,7 +6,7 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
namespace AipsCore.Domain.Models.Shape.Sub.Line;
public class Line : Shape
public partial class Line : Shape
{
public Position EndPosition { get; private set; }
public Thickness Thickness { get; private set; }

View File

@@ -0,0 +1,11 @@
namespace AipsCore.Domain.Models.Shape.Sub.Rectangle;
public partial class Rectangle
{
public override void Move(int newPositionX, int newPositionY)
{
EndPosition.X += newPositionX - Position.X;
EndPosition.Y += newPositionY - Position.Y;
base.Move(newPositionX, newPositionY);
}
}

View File

@@ -6,11 +6,11 @@ using AipsCore.Domain.Models.Whiteboard.ValueObjects;
namespace AipsCore.Domain.Models.Shape.Sub.Rectangle;
public class Rectangle : Shape
public partial class Rectangle : Shape
{
public override ShapeType ShapeType => ShapeType.Rectangle;
public Position EndPosition { get; }
public Position EndPosition { get; set; }
public Thickness BorderThickness { get; }

View File

@@ -0,0 +1,9 @@
using AipsCore.Domain.Abstract.Validation;
using AipsCore.Domain.Models.Shape.ValueObjects;
namespace AipsCore.Domain.Models.Shape.Validation;
public class ShapeErrors : AbstractErrors<Shape, ShapeId>
{
}

View File

@@ -5,8 +5,8 @@ namespace AipsCore.Domain.Models.Shape.ValueObjects;
public record Position : AbstractValueObject
{
public int X { get; }
public int Y { get; }
public int X { get; set; }
public int Y { get; set; }
public Position(int x, int y)
{
@@ -20,4 +20,14 @@ public record Position : AbstractValueObject
];
}
public static Position operator -(Position position, Position otherPosition)
{
return new Position(position.X - otherPosition.X, position.Y - otherPosition.Y);
}
public static Position operator +(Position position, Position otherPosition)
{
return new Position(position.X + otherPosition.X, position.Y + otherPosition.Y);
}
};

View File

@@ -25,6 +25,7 @@ public static partial class ShapeMappers
return Rectangle.Create(
shape.Id.ToString(),
shape.WhiteboardId.ToString(),
shape.AuthorId.ToString(),
shape.PositionX, shape.PositionY,
shape.Color,
shape.EndPositionX!.Value, shape.EndPositionY!.Value,

View File

@@ -1,6 +1,9 @@
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Common.Message.MoveShape;
using AipsCore.Application.Models.Shape.Command.MoveShape;
using AipsRT.Model.Whiteboard;
using AipsRT.Model.Whiteboard.Shapes;
using AipsRT.Model.Whiteboard.Structs;
using AipsRT.Services.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
@@ -41,17 +44,89 @@ public class WhiteboardHub : Hub
.SendAsync("Leaved", Context.UserIdentifier!);
}
private Guid CurrentUserId => Guid.Parse(Context.UserIdentifier!);
private Whiteboard CurrentWhiteboard => _whiteboardManager.GetWhiteboardForUser(CurrentUserId)!;
private async Task ResetCurrentUser()
{
await Clients.Caller.SendAsync("InitWhiteboard", CurrentWhiteboard);
}
private async Task SendToOthers(string methodName, object? arg)
{
await Clients.GroupExcept(CurrentWhiteboard.WhiteboardId.ToString(), Context.ConnectionId)
.SendAsync(methodName, arg);
}
public async Task AddRectangle(Rectangle rectangle)
{
var whiteboard = _whiteboardManager.GetWhiteboardForUser(Guid.Parse(Context.UserIdentifier!))!;
rectangle.OwnerId = Guid.Parse(Context.UserIdentifier!);
rectangle.OwnerId = CurrentUserId;
var whiteboard = CurrentWhiteboard;
await _messagingService.CreatedRectangle(whiteboard.WhiteboardId, rectangle);
whiteboard.AddRectangle(rectangle);
await Clients.GroupExcept(whiteboard.WhiteboardId.ToString(), Context.ConnectionId)
.SendAsync("AddedRectangle", rectangle);
await SendToOthers("AddedRectangle", rectangle);
}
public async Task AddArrow(Arrow arrow)
{
arrow.OwnerId = CurrentUserId;
var whiteboard = CurrentWhiteboard;
await _messagingService.CreatedArrow(whiteboard.WhiteboardId, arrow);
whiteboard.AddArrow(arrow);
await SendToOthers("AddedArrow", arrow);
}
public async Task AddLine(Line line)
{
line.OwnerId = CurrentUserId;
var whiteboard = CurrentWhiteboard;
await _messagingService.CreateLine(whiteboard.WhiteboardId, line);
whiteboard.AddLine(line);
await SendToOthers("AddedLine", line);
}
public async Task AddTextShape(TextShape textShape)
{
textShape.OwnerId = CurrentUserId;
var whiteboard = CurrentWhiteboard;
await _messagingService.CreateTextShape(whiteboard.WhiteboardId, textShape);
whiteboard.AddTextShape(textShape);
await SendToOthers("AddedTextShape", textShape);
}
public async Task MoveShape(MoveShapeCommand moveShape)
{
var whiteboard = CurrentWhiteboard;
var shape = whiteboard.Shapes.Find(s => s.Id.ToString() == moveShape.ShapeId);
if (shape is null || shape.OwnerId != CurrentUserId)
{
await ResetCurrentUser();
return;
}
shape.Move(new Position(moveShape.NewPositionX, moveShape.NewPositionY));
await SendToOthers("MovedShape", moveShape);
}
public async Task PlaceShape(MoveShapeCommand moveShape)
{
await MoveShape(moveShape);
await _messagingService.MoveShape(moveShape);
}
}

View File

@@ -7,4 +7,11 @@ public class Arrow : Shape
public Position EndPosition { get; set; }
public int Thickness { get; set; }
public override void Move(Position newPosition)
{
var difference = newPosition - EndPosition;
EndPosition += difference;
base.Move(newPosition);
}
}

View File

@@ -7,4 +7,11 @@ public class Line : Shape
public Position EndPosition { get; set; }
public int Thickness { get; set; }
public override void Move(Position newPosition)
{
var difference = newPosition - EndPosition;
EndPosition += difference;
base.Move(newPosition);
}
}

View File

@@ -11,6 +11,7 @@ public static class ShapeMappingExtensions
return new Rectangle()
{
Id = shape.Id,
OwnerId = shape.AuthorId,
Position = new Position(shape.PositionX, shape.PositionY),
Color = shape.Color,
EndPosition = new Position(shape.EndPositionX!.Value, shape.EndPositionY!.Value),
@@ -23,6 +24,7 @@ public static class ShapeMappingExtensions
return new Arrow()
{
Id = shape.Id,
OwnerId = shape.AuthorId,
Position = new Position(shape.PositionX, shape.PositionY),
Color = shape.Color,
EndPosition = new Position(shape.EndPositionX!.Value, shape.EndPositionY!.Value),
@@ -35,6 +37,7 @@ public static class ShapeMappingExtensions
return new Line()
{
Id = shape.Id,
OwnerId = shape.AuthorId,
Position = new Position(shape.PositionX, shape.PositionY),
Color = shape.Color,
EndPosition = new Position(shape.EndPositionX!.Value, shape.EndPositionY!.Value),
@@ -47,6 +50,7 @@ public static class ShapeMappingExtensions
return new TextShape()
{
Id = shape.Id,
OwnerId = shape.AuthorId,
Position = new Position(shape.PositionX, shape.PositionY),
Color = shape.Color,
TextValue = shape.TextValue!,

View File

@@ -7,4 +7,11 @@ public class Rectangle : Shape
public Position EndPosition { get; set; }
public int BorderThickness { get; set; }
public override void Move(Position newPosition)
{
var difference = newPosition - Position;
EndPosition += difference;
base.Move(newPosition);
}
}

View File

@@ -11,4 +11,9 @@ public abstract class Shape
public Position Position { get; set; }
public string Color { get; set; }
public virtual void Move(Position newPosition)
{
Position = newPosition;
}
}

View File

@@ -10,4 +10,14 @@ public struct Position
X = x;
Y = y;
}
public static Position operator -(Position position, Position otherPosition)
{
return new Position(position.X - otherPosition.X, position.Y - otherPosition.Y);
}
public static Position operator +(Position position, Position otherPosition)
{
return new Position(position.X + otherPosition.X, position.Y + otherPosition.Y);
}
}

View File

@@ -1,3 +1,5 @@
using AipsCore.Application.Models.Shape.Command.CreateTextShape;
using AipsCore.Application.Models.Shape.Command.MoveShape;
using AipsRT.Model.Whiteboard.Shapes;
namespace AipsRT.Services.Interfaces;
@@ -5,4 +7,9 @@ namespace AipsRT.Services.Interfaces;
public interface IMessagingService
{
Task CreatedRectangle(Guid whiteboardId, Rectangle rectangle);
Task CreatedArrow(Guid whiteboardId, Arrow arrow);
Task CreateLine(Guid whiteboardId, Line line);
Task CreateTextShape(Guid whiteboardId, TextShape textShape);
Task MoveShape(MoveShapeCommand moveShape);
}

View File

@@ -1,6 +1,14 @@
using AipsCore.Application.Abstract.MessageBroking;
using AipsCore.Application.Common.Message.AddArrow;
using AipsCore.Application.Common.Message.AddLine;
using AipsCore.Application.Common.Message.AddRectangle;
using AipsCore.Application.Common.Message.AddTextShape;
using AipsCore.Application.Common.Message.MoveShape;
using AipsCore.Application.Models.Shape.Command.CreateArrow;
using AipsCore.Application.Models.Shape.Command.CreateLine;
using AipsCore.Application.Models.Shape.Command.CreateRectangle;
using AipsCore.Application.Models.Shape.Command.CreateTextShape;
using AipsCore.Application.Models.Shape.Command.MoveShape;
using AipsRT.Model.Whiteboard.Shapes;
using AipsRT.Services.Interfaces;
@@ -33,4 +41,63 @@ public class MessagingService : IMessagingService
await _messagePublisher.PublishAsync(message);
}
public async Task CreatedArrow(Guid whiteboardId, Arrow arrow)
{
var command = new CreateArrowCommand(
arrow.Id.ToString(),
whiteboardId.ToString(),
arrow.OwnerId.ToString(),
arrow.Position.X,
arrow.Position.Y,
arrow.Color,
arrow.EndPosition.X,
arrow.EndPosition.Y,
arrow.Thickness);
var message = new AddArrowMessage(command);
await _messagePublisher.PublishAsync(message);
}
public async Task CreateLine(Guid whiteboardId, Line line)
{
var command = new CreateLineCommand(
line.Id.ToString(),
whiteboardId.ToString(),
line.OwnerId.ToString(),
line.Position.X,
line.Position.Y,
line.Color,
line.EndPosition.X,
line.EndPosition.Y,
line.Thickness);
var message = new AddLineMessage(command);
await _messagePublisher.PublishAsync(message);
}
public async Task CreateTextShape(Guid whiteboardId, TextShape textShape)
{
var command = new CreateTextShapeCommand(
textShape.Id.ToString(),
whiteboardId.ToString(),
textShape.OwnerId.ToString(),
textShape.Position.X,
textShape.Position.Y,
textShape.Color,
textShape.TextValue,
textShape.TextSize);
var message = new AddTextShapeMessage(command);
await _messagePublisher.PublishAsync(message);
}
public async Task MoveShape(MoveShapeCommand moveShape)
{
var message = new MoveShapeMessage(moveShape);
await _messagePublisher.PublishAsync(message);
}
}

View File

@@ -8,6 +8,7 @@ using AipsCore.Application.Models.User.Command.LogOutAll;
using AipsCore.Application.Models.User.Command.RefreshLogIn;
using AipsCore.Application.Models.User.Command.SignUp;
using AipsCore.Application.Models.User.Query.GetMe;
using AipsCore.Application.Models.User.Query.GetUser;
using AipsCore.Infrastructure.Persistence.User;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -80,4 +81,14 @@ public class UserController : ControllerBase
var result = await _dispatcher.Execute(new GetMeQuery(), cancellationToken);
return result;
}
[Authorize]
[HttpGet]
public async Task<ActionResult<User>> GetUser(string userId, CancellationToken cancellationToken)
{
var query = new GetUserQuery(userId);
var result = await _dispatcher.Execute(query, cancellationToken);
return Ok(result);
}
}