namespace ROLAC.API.DTOs.Permissions;
/// Effective action flags for one module (union across a user's roles).
public class ModuleActions
{
public bool Read { get; set; }
public bool Write { get; set; }
public bool Delete { get; set; }
public bool Approve { get; set; }
public bool Any => Read || Write || Delete || Approve;
}
/// One module's grant for a single role — used in the admin matrix and updates.
public class ModulePermissionDto
{
public string Module { get; set; } = null!;
public bool CanRead { get; set; }
public bool CanWrite { get; set; }
public bool CanDelete { get; set; }
public bool CanApprove { get; set; }
}
/// One role's full row in the admin matrix (every module, dense).
public class RolePermissionRow
{
public string RoleName { get; set; } = null!;
public string? Description { get; set; }
/// super_admin is shown read-only/full — it bypasses the matrix.
public bool IsSuperAdmin { get; set; }
public List Modules { get; set; } = [];
}
/// GET /api/permissions — the whole matrix plus the catalog for grid headers.
public class PermissionMatrixDto
{
public IReadOnlyList AllModules { get; set; } = [];
public IReadOnlyList AllActions { get; set; } = [];
public List Roles { get; set; } = [];
}
/// GET /api/permissions/catalog — module + action names for building the UI.
public class PermissionCatalogDto
{
public IReadOnlyList Modules { get; set; } = [];
public IReadOnlyList Actions { get; set; } = [];
}
/// PUT /api/permissions/{roleName} — replaces a role's grants.
public class UpdateRolePermissionsRequest
{
public List Modules { get; set; } = [];
}