mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Adds authorization roles administrator dashboard
This commit is contained in:
1 parent
290af03c83
commit
1df31515fb
191 files changed
+6189
-806
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.AddRole;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddRoleRequest"/>.
|
||||
/// </summary>
|
||||
public static class AddRoleRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="AddRoleCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static AddRoleCommand ToCommand(this AddRoleRequest request)
|
||||
{
|
||||
return new AddRoleCommand(
|
||||
request.RoleName!,
|
||||
request.Permissions!
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.DeleteRole;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateRoleRequest"/>.
|
||||
/// </summary>
|
||||
public static class DeleteRoleRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="DeleteRoleCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static DeleteRoleCommand ToCommand(this DeleteRoleRequest request)
|
||||
{
|
||||
return new DeleteRoleCommand(
|
||||
request.RoleId!.Value
|
||||
);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetRolePermissionsRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetRolePermissionsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetRolePermissionsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetRolePermissionsQuery ToQuery(this GetRolePermissionsRequest request)
|
||||
{
|
||||
return new GetRolePermissionsQuery(
|
||||
request.RoleId
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="PermissionEntity"/>.
|
||||
/// </summary>
|
||||
public static class PermissionEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="PermissionResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static PermissionResponse ToResponse(this PermissionEntity repositoryEntity)
|
||||
{
|
||||
return new PermissionResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.PermissionName
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="PermissionResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<PermissionResponse> ToResponses(this IEnumerable<PermissionEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(permission => permission.ToResponse());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="RoleEntity"/>.
|
||||
/// </summary>
|
||||
public static class RoleEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="RoleResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static RoleResponse ToResponse(this RoleEntity repositoryEntity)
|
||||
{
|
||||
return new RoleResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.RoleName
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="RoleResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static RolePermissionsResponse ToRolePermissionsResponse(this RoleEntity repositoryEntity)
|
||||
{
|
||||
return new RolePermissionsResponse(
|
||||
new RoleDto(repositoryEntity.Id, repositoryEntity.RoleName),
|
||||
repositoryEntity.RolePermissions.Select(rolePermission => rolePermission.ToResponse()).ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="RoleResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<RoleResponse> ToResponses(this IEnumerable<RoleEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(role => role.ToResponse());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="RolePermissionEntity"/>.
|
||||
/// </summary>
|
||||
public static class RolePermissionEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="RolePermissionsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static PermissionDto ToResponse(this RolePermissionEntity repositoryEntity)
|
||||
{
|
||||
return new PermissionDto(
|
||||
repositoryEntity.PermissionId,
|
||||
repositoryEntity.Permission.PermissionName
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.UpdateRole;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateRoleRequest"/>.
|
||||
/// </summary>
|
||||
public static class UpdateRoleRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateRoleCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static UpdateRoleCommand ToCommand(this UpdateRoleRequest request)
|
||||
{
|
||||
return new UpdateRoleCommand(
|
||||
request.RoleId!.Value,
|
||||
request.RoleName!,
|
||||
request.Permissions!
|
||||
);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -11,16 +11,16 @@ namespace Lumina.Application.Common.Mapping.Authorization;
|
||||
public static class UserAuthorizationEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="infrastructureEntity"/> to <see cref="GetAuthorizationResponse"/>.
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="AuthorizationResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="infrastructureEntity">The infrastructure entity to be converted.</param>
|
||||
/// <param name="repositoryEntity">The infrastructure entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static GetAuthorizationResponse ToResponse(this UserAuthorizationEntity infrastructureEntity)
|
||||
public static AuthorizationResponse ToResponse(this UserAuthorizationEntity repositoryEntity)
|
||||
{
|
||||
return new GetAuthorizationResponse(
|
||||
infrastructureEntity.UserId,
|
||||
infrastructureEntity.Roles,
|
||||
infrastructureEntity.Permissions
|
||||
return new AuthorizationResponse(
|
||||
repositoryEntity.UserId,
|
||||
repositoryEntity.Roles,
|
||||
repositoryEntity.Permissions
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user