Granular permission back end done
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class Feature
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public required string Name { get; set; }
|
||||
public ICollection<FeatureAction> Actions { get; set; } = new List<FeatureAction>();
|
||||
public ICollection<ModuleFeature> Modules { get; set; } = new List<ModuleFeature>();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class FeatureAction
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(Feature))]
|
||||
public int FeatureId { get; set; }
|
||||
|
||||
public Feature Feature { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(Action))]
|
||||
public int ActionId { get; set; }
|
||||
|
||||
public PermissionAction Action { get; set; }
|
||||
|
||||
public ICollection<RolePermission> RolePermissions { get; set; } = new List<RolePermission>();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class Module : SoftDeleteEntityBase
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public required string Name { get; set; }
|
||||
|
||||
public ICollection<ModuleFeature> Features { get; set; } = new List<ModuleFeature>();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class ModuleFeature
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(Module))]
|
||||
public int ModuleId { get; set; }
|
||||
|
||||
public Module Module { get; set; }
|
||||
|
||||
[ForeignKey(nameof(Feature))]
|
||||
public int FeatureId { get; set; }
|
||||
|
||||
public Feature Feature { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class PermissionAction
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public required string Name { get; set; }
|
||||
|
||||
public ICollection<FeatureAction> Features { get; set; } = new List<FeatureAction>();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using FJPSite.Data.Identity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class RolePermission
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(Role))]
|
||||
public string RoleId { get; set; }
|
||||
|
||||
public RoleEntity Role { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(FeatureAction))]
|
||||
public int FeatureActionId { get; set; }
|
||||
|
||||
public FeatureAction FeatureAction { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using FJPSite.Data.Identity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace FJPSite.Data.Authorisation;
|
||||
|
||||
public class UserPermission
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(User))]
|
||||
public string UserId { get; set; }
|
||||
|
||||
public UserEntity User { get; set; }
|
||||
|
||||
[Required, ForeignKey(nameof(FeatureAction))]
|
||||
public int FeatureActionId { get; set; }
|
||||
|
||||
public FeatureAction FeatureAction { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user