using iWareCommon.Common.Entity;
using iWareCommon.Utils;
using iWareDataCore.ORM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace iWareDataCore.RBAC.Entity
{
///
/// 用户
///
public class UserEntity : ICommonEntity
{
///
/// 主键
///
public int Id { get; set; }
///
/// 用户名
///
public string Username { get; set; }
///
/// 密码
///
public string Password { get; set; }
///
/// 姓名
///
public string Name { get; set; }
///
/// 工号
///
public string WorkNo { get; set; }
///
/// 职位
///
public string Position { get; set; }
///
/// 照片
///
public string Photo { get; set; }
///
/// 电话
///
public string Tel { get; set; }
///
/// 启用、锁定状态
///
public int Status { get; set; }
///
/// 删除状态
///
public int label { get; set; }
///
/// 角色名显示字段
///
public string DisplayRoleNames { get; set; }
///
/// 角色
///
public List Roles { get; set; }
///
/// 带权限值的目录(BS端)
///
public List Contents { get; set; }
///
/// 带权限值的目录(CSS端)
///
public List CsContents { get; set; }
///
/// 构造函数
///
public UserEntity() { }
///
/// 构造函数
///
/// Orm中的用户实体
public UserEntity(RBACUser user)
{
EntityPropHelper.CopyProp(user, this, GetColumnMap());
this.DisplayRoleNames = "";
this.Roles = new List();
this.Contents = new List();
this.CsContents = new List();
}
///
/// 将用户实体转成orm中的用户类型
///
/// orm中的用户类型
public RBACUser ToOrm()
{
var user = new RBACUser();
EntityPropHelper.CopyProp(this, user, GetColumnMap());
return user;
}
///
/// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段
///
///
public static Dictionary GetColumnMap()
{
return new Dictionary()
{
{"Id", "id"},
{"Username", "username"},
{"Password", "password"},
{"Name", "name"},
{"WorkNo", "workno"},
{"Position", "position"},
{"Photo", "photo"},
{"Tel", "tel"},
{"Status", "status"}
};
}
///
/// 根据UserEntity的字段转RBAC_User的字段
///
/// UserEntity的字段
/// RBAC_User
public static string GetColumnName(string name)
{
var columnMap = GetColumnMap();
return columnMap.ContainsKey(name) ? columnMap[name] : name;
}
///
/// 获取UserEntity对于的表名
///
/// RBAC_User
public static string GetTableName()
{
return "[dbo].[RBACUser]";
}
}
}