一般后台管理会涉及到角色权限的管理。
首先设计的对象 用户(User),系统权限(Action),部门(Department),
关系表有用户角色表(UserRole),角色权限(RoleAction)。就这么简单!
/// <summary> /// 系统用户表 /// </summary> [Table("Base_User")] public class Base_User { /// <summary> /// 主键 /// </summary> [Key, Column(Order = 1)] public String Id { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTime CreateTime { get; set; } /// <summary> /// 创建人Id /// </summary> public String CreatorId { get; set; } /// <summary> /// 否已删除 /// </summary> public Boolean Deleted { get; set; } /// <summary> /// 用户名 /// </summary> public String UserName { get; set; } /// <summary> /// 密码 /// </summary> public String Password { get; set; } /// <summary> /// 姓名 /// </summary> public String RealName { get; set; } /// <summary> /// 性别 /// </summary> public Sex Sex { get; set; } /// <summary> /// 出生日期 /// </summary> public DateTime? Birthday { get; set; } /// <summary> /// 所属部门Id /// </summary> public String DepartmentId { get; set; } /// <summary> /// 商户Id /// </summary> public string BusinessId { get; set; } } public enum Sex { [Description("男")] Man = 1, [Description("女")] Woman = 0 } /// <summary> /// 系统权限表 /// </summary> [Table("Base_Action")] public class Base_Action { /// <summary> /// 主键 /// </summary> [Key, Column(Order = 1)] public String Id { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTime CreateTime { get; set; } /// <summary> /// 创建人Id /// </summary> public String CreatorId { get; set; } /// <summary> /// 否已删除 /// </summary> public Boolean Deleted { get; set; } /// <summary> /// 父级Id /// </summary> public String ParentId { get; set; } /// <summary> /// 类型,菜单=0,页面=1,权限=2 /// </summary> public ActionType Type { get; set; } /// <summary> /// 权限名/菜单名 /// </summary> public String Name { get; set; } /// <summary> /// 菜单地址 /// </summary> public String Url { get; set; } /// <summary> /// 权限值 /// </summary> public String Value { get; set; } /// <summary> /// 是否需要权限(仅页面有效) /// </summary> public bool NeedAction { get; set; } /// <summary> /// 图标 /// </summary> public string Icon { get; set; } /// <summary> /// 排序 /// </summary> public int Sort { get; set; } } /// <summary> /// 部门表 /// </summary> [Table("Base_Department")] public class Base_Department { /// <summary> /// 主键 /// </summary> [Key, Column(Order = 1)] public String Id { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTime CreateTime { get; set; } /// <summary> /// 创建人Id /// </summary> public String CreatorId { get; set; } /// <summary> /// 否已删除 /// </summary> public Boolean Deleted { get; set; } /// <summary> /// 部门名 /// </summary> public String Name { get; set; } /// <summary> /// 上级部门Id /// </summary> public String ParentId { get; set; } } /// <summary> /// 系统角色表 /// </summary> [Table("Base_Role")] public class Base_Role { /// <summary> /// 主键 /// </summary> [Key, Column(Order = 1)] public String Id { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTime CreateTime { get; set; } /// <summary> /// 创建人Id /// </summary> public String CreatorId { get; set; } /// <summary> /// 否已删除 /// </summary> public Boolean Deleted { get; set; } /// <summary> /// 角色名 /// </summary> public String RoleName { get; set; } } /// <summary> /// 角色权限表 /// </summary> [Table("Base_RoleAction")] public class Base_RoleAction { /// <summary> /// 主键 /// </summary> [Key, Column(Order = 1)] public String Id { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTime CreateTime { get; set; } /// <summary> /// 创建人Id /// </summary> public String CreatorId { get; set; } /// <summary> /// 否已删除 /// </summary> public Boolean Deleted { get; set; } /// <summary> /// 用户Id /// </summary> public String RoleId { get; set; } /// <summary> /// 权限Id /// </summary> public String ActionId { get; set; } } /// <summary> /// 用户角色表 /// </summary> [Table("Base_UserRole")] public class Base_UserRole { /// <summary> /// 主键 /// </summary> [Key, Column(Order = 1)] public String Id { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTime CreateTime { get; set; } /// <summary> /// 创建人Id /// </summary> public String CreatorId { get; set; } /// <summary> /// 否已删除 /// </summary> public Boolean Deleted { get; set; } /// <summary> /// 用户Id /// </summary> public String UserId { get; set; } /// <summary> /// 角色Id /// </summary> public String RoleId { get; set; } }