Implement dynamic group management features with exclusions and mode handling
Enhanced the group management system by introducing dynamic group capabilities, allowing for the exclusion of elements from dynamic groups. Updated the Group and GroupItem models to support a new GroupMode, enabling the distinction between static and dynamic groups. Implemented API endpoints for excluding elements and updated related services to handle group composition based on the selected mode. Improved the frontend to accommodate these changes, including new API functions and UI components for managing exclusions and group modes, thereby enhancing the overall user experience in group management.
This commit is contained in:
@@ -4,6 +4,7 @@ using TeleWave.Application.Programming.Groups;
|
||||
using TeleWave.Application.Programming.Groups.AddGroupElements;
|
||||
using TeleWave.Application.Programming.Groups.CreateGroup;
|
||||
using TeleWave.Application.Programming.Groups.DeleteGroup;
|
||||
using TeleWave.Application.Programming.Groups.ExcludeGroupElement;
|
||||
using TeleWave.Application.Programming.Groups.FindGroupCandidates;
|
||||
using TeleWave.Application.Programming.Groups.GetGroup;
|
||||
using TeleWave.Application.Programming.Groups.ListGroups;
|
||||
@@ -12,6 +13,7 @@ using TeleWave.Application.Programming.Groups.ReorderGroup;
|
||||
using TeleWave.Application.Programming.Groups.SetGroupItemWeight;
|
||||
using TeleWave.Application.Programming.Groups.Suggest;
|
||||
using TeleWave.Application.Programming.Groups.UpdateGroup;
|
||||
using TeleWave.Domain.Programming;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
|
||||
namespace TeleWave.Api.Endpoints;
|
||||
@@ -50,6 +52,9 @@ public static class GroupEndpoints
|
||||
.Produces(StatusCodes.Status204NoContent);
|
||||
admin.MapPut("/{id:guid}/order", Reorder).Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
// Поправки к вычисленному составу динамической группы.
|
||||
admin.MapPost("/{id:guid}/exclusions", Exclude).Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@@ -122,7 +127,7 @@ public static class GroupEndpoints
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateGroupCommand(id, body.Name, body.Description, body.Filter),
|
||||
new UpdateGroupCommand(id, body.Name, body.Description, body.Filter, body.Mode),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
@@ -194,6 +199,20 @@ public static class GroupEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> Exclude(
|
||||
Guid id,
|
||||
ExcludeElementBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new ExcludeGroupElementCommand(id, body.ElementKind, body.ElementId, body.Excluded),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> Reorder(
|
||||
Guid id,
|
||||
ReorderGroupBody body,
|
||||
@@ -209,7 +228,19 @@ public static class GroupEndpoints
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record UpdateGroupBody(string Name, string? Description, GroupFilter? Filter);
|
||||
public sealed record UpdateGroupBody(
|
||||
string Name,
|
||||
string? Description,
|
||||
GroupFilter? Filter,
|
||||
GroupMode? Mode = null
|
||||
);
|
||||
|
||||
/// <summary>Исключить элемент из динамической группы либо вернуть его правилу.</summary>
|
||||
public sealed record ExcludeElementBody(
|
||||
GroupElementKind ElementKind,
|
||||
Guid ElementId,
|
||||
bool Excluded
|
||||
);
|
||||
|
||||
public sealed record FindCandidatesBody(GroupFilter? Filter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user