liany920

导航

RBAC经典的五张表

  • RBAC基于角色的访问控制(Role-Based Access Control),能更方便企业进行用户权限的管理。
    下面是RBAC经典的五张表:

    1.用户表:
点击查看代码
 /// <summary>
    /// 用户表
    /// </summary>
    [Table("Users")]
    public class Users
    {
        [Key]
        public int UserId { get; set; }
        [Required]
        [StringLength(50)]
        public string UserName { get; set; }
        [Required]
        [StringLength(50)]
        public string PassWord { get; set; }
        public int Age { get; set; }
        [StringLength(50)]
        public string? Email { get; set; }
        [StringLength(11)]
        public string? Phone { get; set; }
        [Required]
        [StringLength(50)]
        public string TrueName { get; set; }
    }
2.角色表:
点击查看代码
 /// <summary>
    /// 角色表
    /// </summary>
    [Table("Roles")]
    public class Roles
    {
        [Key]
        public int RoleId { get; set; }
        [Required]
        [StringLength(50)]
        public string RoleName { get; set; }
        [StringLength(50)]
        public string? Desc { get; set; }
    }
3.权限表:
点击查看代码
 /// <summary>
    /// 权限表
    /// </summary>
    [Table("Permision")]
    public class Permision
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public string PermisionId { get; set; }
        [Required]
        [StringLength(50)]
        public string PermisionName { get; set; }
        [Required]
        [StringLength(50)]
        public string ParentId { get; set; }
        [Required]
        [StringLength(500)]
        public string MenuUrl { get; set; }
        [Required]
        [StringLength(500)]
        public string Icon { get; set; }
    }
4.用户角色关系表:
点击查看代码
/// <summary>
    /// 用户角色关系表
    /// </summary>
    [Table("UserRole")]
    public class UserRole
    {
        [Key]
        public int UserRoleId { get; set; }
        public int UserId { get; set; }
        public int RoleId { get; set; }
    }
5.角色权限关系表:
点击查看代码
 /// <summary>
    /// 角色权限关系表
    /// </summary>
    [Table("RolePermision")]
    public class RolePermision
    {
        [Key]
        public int RolePermisionId { get; set; }

        public int RoleId { get; set; }
        public string PermisionId { get; set; }
    }

posted on 2024-02-22 20:59  练练练  阅读(389)  评论(0)    收藏  举报