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 RoleUserEntity : ICommonEntity { /// /// 主键 /// public int Id { get; set; } /// /// 用户Id /// public int UserId { get; set; } /// /// 角色Id /// public int RoleId { get; set; } /// /// 构造函数 /// public RoleUserEntity() { } /// /// 构造函数 /// /// orm中的角色-用户实体 public RoleUserEntity(RBACRoleUser roleUser) { EntityPropHelper.CopyProp(roleUser, this, GetColumnMap()); } /// /// 将对象转换成ORM中的类型 /// /// Orm中的角色-用户类型 public RBACRoleUser ToOrm() { var roleUser = new RBACRoleUser(); EntityPropHelper.CopyProp(this, roleUser, GetColumnMap()); return roleUser; } /// /// 获取自定义角色-用户类中的字段名为键,orm中对象的字段名为值的字典 /// /// 自定义角色-用户类中的字段名为键,orm中对象的字段名为值的字典 public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"UserId", "userid"}, {"RoleId", "roleid"} }; } /// /// 根据USerRoleEntity的字段转RBACUserRole的字段 /// /// UserRoleEntity的字段 /// RBACUserRole中的字段 public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取UserRoleEntity对应的表名 /// /// UserRoleEntity public static string GetTableName() { return "[dbo].[RBACRoleUser]"; } } }