Files
wcs/WCS.DAL/Db/AuthDb/AuthModels.cs
hehaibing-1996 d283924ae1 提交代码
2024-05-03 11:04:59 +08:00

84 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using WCS.DAL.Db;
using WCS.Model;
namespace WCS.DAL.Db.AuthDb
{
/// <summary>
/// 用户
/// </summary>
[SugarTable("User")]
public class UserBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 登录名
/// </summary>
public string LoginName { get; set; }
/// <summary>
/// 密码
/// </summary>
public string Password { get; set; }
/// <summary>
/// 角色idjson
/// </summary>
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString, IsJson = true)]
public List<int> RoleIds { get; set; } = new List<int>();
/// <summary>
/// 角色名称
/// </summary>
[SugarColumn(IsIgnore = true)]
public List<string> RoleNames { get => RoleIds == null || !RoleIds.Any() ? new List<string>() : AuthDbHelp.db.Queryable<RoleBase>().Where(o => RoleIds.Contains(o.Id)).Select(o => o.Name).ToList(); }
/// <summary>
/// 是否最大权限
/// </summary>
public bool IsAdmin { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 用户所属角色
/// </summary>
[SugarColumn(IsIgnore = true)]
public List<RoleBase> GetRoles { get; set; }
}
/// <summary>
/// 角色
/// </summary>
[SugarTable("Role")]
public class RoleBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 角色名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 认证模块json
/// </summary>
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString, IsJson = true)]
public List<int> Auths { get; set; } = new List<int>();
/// <summary>
/// 认证模块名称
/// </summary>
[SugarColumn(IsIgnore = true)]
public List<string> AuthNames { get => Auths == null || !Auths.Any() ? new List<string>() : EnumHelps.GetEnumDescriptionList(typeof(AuthEnum), true).Where(o => Auths.Contains(o.Item1)).Select(o => o.Item3).ToList(); }
/// <summary>
/// 是否最大权限
/// </summary>
public bool IsAdmin { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime Time { get; set; }
}
}