feat(pos): implement table-based ordering, kitchen ticket workflow, and table floor plan management
This commit is contained in:
@@ -12,5 +12,7 @@ namespace FnbEngine.API.Application.Commands;
|
||||
public record UpdateTableCommand(
|
||||
Guid TableId,
|
||||
int? Capacity = null,
|
||||
string? Zone = null
|
||||
string? Zone = null,
|
||||
int? PositionX = null,
|
||||
int? PositionY = null
|
||||
) : IRequest<bool>;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// EN: Handler for UpdateTableCommand.
|
||||
// VI: Handler cho UpdateTableCommand.
|
||||
|
||||
using MediatR;
|
||||
using FnbEngine.Domain.AggregatesModel.TableAggregate;
|
||||
|
||||
namespace FnbEngine.API.Application.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// EN: Handler for updating table details.
|
||||
/// VI: Handler cập nhật thông tin bàn.
|
||||
/// </summary>
|
||||
public class UpdateTableCommandHandler : IRequestHandler<UpdateTableCommand, bool>
|
||||
{
|
||||
private readonly ITableRepository _tableRepository;
|
||||
private readonly ILogger<UpdateTableCommandHandler> _logger;
|
||||
|
||||
public UpdateTableCommandHandler(
|
||||
ITableRepository tableRepository,
|
||||
ILogger<UpdateTableCommandHandler> logger)
|
||||
{
|
||||
_tableRepository = tableRepository ?? throw new ArgumentNullException(nameof(tableRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public async Task<bool> Handle(UpdateTableCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Updating table {TableId}", request.TableId);
|
||||
|
||||
var table = await _tableRepository.GetByIdAsync(request.TableId, cancellationToken);
|
||||
if (table == null)
|
||||
throw new InvalidOperationException($"Table not found: {request.TableId}");
|
||||
|
||||
if (request.PositionX.HasValue && request.PositionY.HasValue)
|
||||
table.SetPosition(request.PositionX.Value, request.PositionY.Value);
|
||||
|
||||
_tableRepository.Update(table);
|
||||
await _tableRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
|
||||
|
||||
_logger.LogInformation("Updated table {TableId}", request.TableId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,7 @@ public record TableDto(
|
||||
string TableNumber,
|
||||
int Capacity,
|
||||
string? Zone,
|
||||
string Status
|
||||
string Status,
|
||||
int? PositionX = null,
|
||||
int? PositionY = null
|
||||
);
|
||||
|
||||
@@ -33,7 +33,9 @@ public class GetTablesQueryHandler : IRequestHandler<GetTablesQuery, IEnumerable
|
||||
t.TableNumber,
|
||||
t.Capacity,
|
||||
t.Zone,
|
||||
allStatuses.TryGetValue(t.StatusId, out var name) ? name : "available"
|
||||
allStatuses.TryGetValue(t.StatusId, out var name) ? name : "available",
|
||||
t.PositionX,
|
||||
t.PositionY
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,29 @@ public class TablesController : ControllerBase
|
||||
new ApiResponse<CreateTableResult> { Success = true, Data = result });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EN: Update table details.
|
||||
/// VI: Cập nhật thông tin bàn.
|
||||
/// </summary>
|
||||
[HttpPut("{id}")]
|
||||
[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
|
||||
[ProducesResponseType(404)]
|
||||
public async Task<ActionResult<ApiResponse<bool>>> UpdateTable(
|
||||
Guid id,
|
||||
[FromBody] UpdateTableRequest request,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var command = new UpdateTableCommand(
|
||||
id,
|
||||
request.Capacity,
|
||||
request.Zone,
|
||||
request.PositionX,
|
||||
request.PositionY);
|
||||
|
||||
var result = await _mediator.Send(command, ct);
|
||||
return Ok(new ApiResponse<bool> { Success = true, Data = result });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EN: Change table status.
|
||||
/// VI: Đổi trạng thái bàn.
|
||||
@@ -91,6 +114,16 @@ public record CreateTableRequest(
|
||||
int Capacity,
|
||||
string? Zone = null);
|
||||
|
||||
/// <summary>
|
||||
/// EN: Request to update table details.
|
||||
/// VI: Request cập nhật thông tin bàn.
|
||||
/// </summary>
|
||||
public record UpdateTableRequest(
|
||||
int? Capacity = null,
|
||||
string? Zone = null,
|
||||
int? PositionX = null,
|
||||
int? PositionY = null);
|
||||
|
||||
/// <summary>
|
||||
/// EN: Request to change table status.
|
||||
/// VI: Request đổi trạng thái bàn.
|
||||
|
||||
Reference in New Issue
Block a user