mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Implement projectable GetId for UserGroup
This commit is contained in:
@@ -33,6 +33,16 @@ namespace Tgstation.Server.Host.Authority
|
||||
[TgsAuthorize(AdministrationRights.ReadUsers)]
|
||||
RequirementsGated<AuthorityResponse<UserGroup>> GetId(long id, bool includeJoins, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="UserGroup"/> with a given <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">The result type after projection.</typeparam>
|
||||
/// <param name="id">The <see cref="Api.Models.EntityId.Id"/> of the <see cref="UserGroup"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
|
||||
/// <returns>A <see cref="RequirementsGated{TResult}"/> <see cref="Projectable{TQueried, TResult}"/> <see cref="User"/> for <typeparamref name="TResult"/>.</returns>
|
||||
RequirementsGated<Projectable<UserGroup, TResult>> GetId<TResult>(long id, CancellationToken cancellationToken)
|
||||
where TResult : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Gets all registered <see cref="UserGroup"/>s.
|
||||
/// </summary>
|
||||
|
||||
@@ -111,6 +111,23 @@ namespace Tgstation.Server.Host.Authority
|
||||
return new AuthorityResponse<UserGroup>(userGroup);
|
||||
});
|
||||
|
||||
/// <inheritdoc />
|
||||
public RequirementsGated<Projectable<UserGroup, TResult>> GetId<TResult>(long id, CancellationToken cancellationToken)
|
||||
where TResult : notnull
|
||||
=> new(
|
||||
() => Flag(AdministrationRights.ReadUsers),
|
||||
() => Projectable<UserGroup, TResult>.Create(
|
||||
QueryableImpl(true)
|
||||
.Where(x => x.Id == id),
|
||||
projectable =>
|
||||
{
|
||||
if (projectable == null)
|
||||
return Gone<TResult>();
|
||||
|
||||
return new AuthorityResponse<TResult>(projectable.Result);
|
||||
},
|
||||
cancellationToken));
|
||||
|
||||
/// <inheritdoc />
|
||||
public RequirementsGated<Projectable<UserGroup, TResult>> Read<TResult>(CancellationToken cancellationToken)
|
||||
where TResult : notnull
|
||||
|
||||
Reference in New Issue
Block a user