feat:furion rbac搭建
This commit is contained in:
85
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/DeptEntity.cs
Normal file
85
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/DeptEntity.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门表
|
||||
///</summary>
|
||||
[SugarTable("Dept")]
|
||||
public partial class DeptEntity : IEntity<long>, ISoftDelete, IAuditedObject, IOrderNum, IState
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 部门名称
|
||||
///</summary>
|
||||
public string DeptName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 部门编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DeptCode")]
|
||||
public string DeptCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 负责人
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Leader")]
|
||||
public string Leader { get; set; }
|
||||
/// <summary>
|
||||
/// 父级id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ParentId")]
|
||||
public long ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Remark")]
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
[SugarTable("LoginLog")]
|
||||
public class LoginLogEntity : IEntity<long>, ICreationAuditedObject
|
||||
{
|
||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录用户
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "LoginUser")]
|
||||
public string LoginUser { get; set; }
|
||||
/// <summary>
|
||||
/// 登录地点
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "LoginLocation")]
|
||||
public string LoginLocation { get; set; }
|
||||
/// <summary>
|
||||
/// 登录Ip
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "LoginIp")]
|
||||
public string LoginIp { get; set; }
|
||||
/// <summary>
|
||||
/// 浏览器
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Browser")]
|
||||
public string Browser { get; set; }
|
||||
/// <summary>
|
||||
/// 操作系统
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Os")]
|
||||
public string Os { get; set; }
|
||||
/// <summary>
|
||||
/// 登录信息
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "LogMsg")]
|
||||
public string LogMsg { get; set; }
|
||||
|
||||
public long? CreatorId { get; set; }
|
||||
}
|
||||
}
|
||||
196
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/MenuEntity.cs
Normal file
196
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/MenuEntity.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
using Yi.Framework.Infrastructure.Helper;
|
||||
using Yi.Furion.Rbac.Core.Dtos;
|
||||
using Yi.Furion.Rbac.Core.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单表
|
||||
///</summary>
|
||||
[SugarTable("Menu")]
|
||||
public partial class MenuEntity : IEntity<long>, ISoftDelete, IAuditedObject, IOrderNum, IState
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单名
|
||||
/// </summary>
|
||||
public string MenuName { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "MenuType")]
|
||||
public MenuTypeEnum MenuType { get; set; } = MenuTypeEnum.Menu;
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PermissionCode")]
|
||||
public string PermissionCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ParentId")]
|
||||
public long ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单图标
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "MenuIcon")]
|
||||
public string MenuIcon { get; set; }
|
||||
/// <summary>
|
||||
/// 菜单组件路由
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Router")]
|
||||
public string Router { get; set; }
|
||||
/// <summary>
|
||||
/// 是否为外部链接
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "IsLink")]
|
||||
public bool IsLink { get; set; }
|
||||
/// <summary>
|
||||
/// 是否缓存
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "IsCache")]
|
||||
public bool IsCache { get; set; }
|
||||
/// <summary>
|
||||
/// 是否显示
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "IsShow")]
|
||||
public bool IsShow { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Remark")]
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// 组件路径
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Component")]
|
||||
public string Component { get; set; }
|
||||
/// <summary>
|
||||
/// 路由参数
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Query")]
|
||||
public string Query { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<MenuEntity> Children { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体扩展
|
||||
/// </summary>
|
||||
public static class MenuEntityExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建vue3路由
|
||||
/// </summary>
|
||||
/// <param name="menus"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Vue3RouterDto> Vue3RouterBuild(this List<MenuEntity> menus)
|
||||
{
|
||||
menus = menus.Where(m => m.MenuType != MenuTypeEnum.Component).ToList();
|
||||
List<Vue3RouterDto> routers = new();
|
||||
foreach (var m in menus)
|
||||
{
|
||||
|
||||
var r = new Vue3RouterDto();
|
||||
r.OrderNum = m.OrderNum;
|
||||
var routerName = m.Router?.Split("/").LastOrDefault();
|
||||
r.Id = m.Id;
|
||||
r.ParentId = m.ParentId;
|
||||
|
||||
//开头大写
|
||||
r.Name = routerName?.First().ToString().ToUpper() + routerName?.Substring(1);
|
||||
r.Path = m.Router!;
|
||||
r.Hidden = !m.IsShow;
|
||||
|
||||
|
||||
if (m.MenuType == MenuTypeEnum.Catalogue)
|
||||
{
|
||||
r.Redirect = "noRedirect";
|
||||
r.AlwaysShow = true;
|
||||
|
||||
//判断是否为最顶层的路由
|
||||
if (0 == m.ParentId)
|
||||
{
|
||||
r.Component = "Layout";
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Component = "ParentView";
|
||||
}
|
||||
}
|
||||
if (m.MenuType == MenuTypeEnum.Menu)
|
||||
{
|
||||
r.Redirect = "noRedirect";
|
||||
r.AlwaysShow = true;
|
||||
r.Component = m.Component!;
|
||||
r.AlwaysShow = false;
|
||||
}
|
||||
r.Meta = new Meta
|
||||
{
|
||||
Title = m.MenuName!,
|
||||
Icon = m.MenuIcon!,
|
||||
NoCache = !m.IsCache
|
||||
};
|
||||
if (m.IsLink)
|
||||
{
|
||||
r.Meta.link = m.Router!;
|
||||
r.AlwaysShow = false;
|
||||
}
|
||||
|
||||
routers.Add(r);
|
||||
}
|
||||
return TreeHelper.SetTree(routers);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/PostEntity.cs
Normal file
74
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/PostEntity.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位表
|
||||
///</summary>
|
||||
[SugarTable("Post")]
|
||||
public partial class PostEntity : IEntity<long>, ISoftDelete, IAuditedObject, IOrderNum, IState
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 岗位编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PostCode")]
|
||||
public string PostCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 岗位名称
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PostName")]
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Remark")]
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 角色部门关系表
|
||||
///</summary>
|
||||
[SugarTable("RoleDept")]
|
||||
public partial class RoleDeptEntity : IEntity<long>
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "RoleId")]
|
||||
public long? RoleId { get; set; }
|
||||
/// <summary>
|
||||
/// 部门id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DeptId")]
|
||||
public long? DeptId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
88
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/RoleEntity.cs
Normal file
88
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/RoleEntity.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
using Yi.Furion.Rbac.Core.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色表
|
||||
/// </summary>
|
||||
[SugarTable("Role")]
|
||||
public class RoleEntity : IEntity<long>, ISoftDelete, IAuditedObject, IOrderNum, IState
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 角色名
|
||||
/// </summary>
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 角色编码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "RoleCode")]
|
||||
public string RoleCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Remark")]
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// 角色数据范围
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "DataScope")]
|
||||
public DataScopeEnum DataScope { get; set; } = DataScopeEnum.ALL;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; } = true;
|
||||
|
||||
|
||||
[Navigate(typeof(RoleMenuEntity), nameof(RoleMenuEntity.RoleId), nameof(RoleMenuEntity.MenuId))]
|
||||
public List<MenuEntity> Menus { get; set; }
|
||||
|
||||
[Navigate(typeof(RoleDeptEntity), nameof(RoleDeptEntity.RoleId), nameof(RoleDeptEntity.DeptId))]
|
||||
public List<DeptEntity> Depts { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities;
|
||||
/// <summary>
|
||||
/// 角色菜单关系表
|
||||
///</summary>
|
||||
[SugarTable("RoleMenu")]
|
||||
public partial class RoleMenuEntity : IEntity<long>
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "RoleId")]
|
||||
public long RoleId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "MenuId")]
|
||||
public long MenuId { get; set; }
|
||||
|
||||
}
|
||||
211
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/UserEntity.cs
Normal file
211
Yi.Furion.Rbac/Yi.Furion.Rbac.Core/Entities/UserEntity.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Data.Auditing;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
using Yi.Framework.Infrastructure.Helper;
|
||||
using Yi.Furion.Rbac.Core.EnumClasses;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户表
|
||||
/// </summary>
|
||||
[SugarTable("User")]
|
||||
public class UserEntity : IEntity<long>, ISoftDelete, IAuditedObject, IOrderNum, IState
|
||||
{
|
||||
public UserEntity()
|
||||
{
|
||||
|
||||
}
|
||||
public UserEntity(string userName, string password, long phone, string nick = "萌新")
|
||||
{
|
||||
Id = SnowflakeHelper.NextId;
|
||||
UserName = userName;
|
||||
Password = password;
|
||||
Phone = phone;
|
||||
Nick = nick;
|
||||
BuildPassword();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年龄
|
||||
/// </summary>
|
||||
public int? Age { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
/// </summary>
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 加密盐值
|
||||
/// </summary>
|
||||
public string Salt { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 头像
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 昵称
|
||||
/// </summary>
|
||||
public string Nick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱
|
||||
/// </summary>
|
||||
public string Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ip
|
||||
/// </summary>
|
||||
public string Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// </summary>
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电话
|
||||
/// </summary>
|
||||
public long? Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 简介
|
||||
/// </summary>
|
||||
public string Introduction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
public SexEnum Sex { get; set; } = SexEnum.Unknown;
|
||||
|
||||
/// <summary>
|
||||
/// 部门id
|
||||
/// </summary>
|
||||
public long? DeptId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public long? CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改者
|
||||
/// </summary>
|
||||
public long? LastModifierId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后修改时间
|
||||
/// </summary>
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public bool State { get; set; } = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 角色
|
||||
/// </summary>
|
||||
[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.UserId), nameof(UserRoleEntity.RoleId))]
|
||||
public List<RoleEntity> Roles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 岗位
|
||||
/// </summary>
|
||||
|
||||
[Navigate(typeof(UserPostEntity), nameof(UserPostEntity.UserId), nameof(UserPostEntity.PostId))]
|
||||
public List<PostEntity> Posts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门
|
||||
/// </summary>
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(DeptId))]
|
||||
public DeptEntity Dept { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建密码,MD5盐值加密
|
||||
/// </summary>
|
||||
public UserEntity BuildPassword(string password = null)
|
||||
{
|
||||
//如果不传值,那就把自己的password当作传进来的password
|
||||
if (password == null)
|
||||
{
|
||||
if (Password == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(Password));
|
||||
}
|
||||
password = Password;
|
||||
}
|
||||
Salt = MD5Helper.GenerateSalt();
|
||||
Password = MD5Helper.SHA2Encode(password, Salt);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断密码和加密后的密码是否相同
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public bool JudgePassword(string password)
|
||||
{
|
||||
if (Salt is null)
|
||||
{
|
||||
throw new ArgumentNullException(Salt);
|
||||
}
|
||||
var p = MD5Helper.SHA2Encode(password, Salt);
|
||||
if (Password == MD5Helper.SHA2Encode(password, Salt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities;
|
||||
/// <summary>
|
||||
/// 用户岗位表
|
||||
///</summary>
|
||||
[SugarTable("UserPost")]
|
||||
public partial class UserPostEntity : IEntity<long>
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 用户id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "UserId")]
|
||||
public long UserId { get; set; }
|
||||
/// <summary>
|
||||
/// 岗位id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PostId")]
|
||||
public long PostId { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Infrastructure.Ddd.Entities;
|
||||
|
||||
namespace Yi.Furion.Rbac.Core.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户角色关系表
|
||||
///</summary>
|
||||
[SugarTable("UserRole")]
|
||||
public partial class UserRoleEntity : IEntity<long>
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色id
|
||||
/// </summary>
|
||||
public long RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户id
|
||||
/// </summary>
|
||||
public long UserId { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user