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 RoleEntity : ICommonEntity
{
///
/// 主键
///
public int Id { get; set; }
///
/// 角色名称
///
public string RoleName { get; set; }
///
/// 备注
///
public string Remark { get; set; }
///
/// 创建时间
///
public DateTime CreateTime { get; set; }
///
/// 创建人员
///
public string CreatePerson { get; set; }
///
/// 构造函数
///
public RoleEntity() { }
///
/// 构造函数
///
/// 角色
public RoleEntity(RBACRole role)
{
EntityPropHelper.CopyProp(role, this, GetColumnMap());
}
///
/// 将对象转换成ORM中的类型
///
/// Orm中的角色类型
public RBACRole ToOrm()
{
RBACRole role = new RBACRole();
EntityPropHelper.CopyProp(this, role, GetColumnMap());
return role;
}
///
/// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段
///
///
public static Dictionary GetColumnMap()
{
return new Dictionary()
{
{"Id", "id"},
{"RoleName", "rolename"},
{"Remark","remark"},
{"CreateTime","createtime"},
{"CreatePerson","createperson"}
};
}
///
/// 根据RoleEntity的字段转RBAC_Role的字段
///
/// RoleEntity的字段
/// RBAC_Role
public static string GetColumnName(string name)
{
var columnMap = GetColumnMap();
return columnMap.ContainsKey(name) ? columnMap[name] : name;
}
///
/// 获取RoleEntity对于的表名
///
/// RBAC_Role
public static string GetTableName()
{
return "[dbo].[RBACRole]";
}
}
}