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 RoleContentEntity : ICommonEntity { /// /// 主键 /// public int Id { get; set; } /// /// 菜单Id /// public int ContentId { get; set; } /// /// 角色Id /// public int RoleId { get; set; } /// /// 权限值 /// public int Value { get; set; } /// /// 构造函数 /// public RoleContentEntity() { } /// /// 构造函数 /// /// orm中的角色-菜单实体 public RoleContentEntity(RBACRoleContent roleContent) { EntityPropHelper.CopyProp(roleContent, this, GetColumnMap()); } /// /// 将对象转换成ORM中的类型 /// /// Orm中的角色-菜单类型 public RBACRoleContent ToOrm() { var roleContent = new RBACRoleContent(); EntityPropHelper.CopyProp(this, roleContent, GetColumnMap()); return roleContent; } /// /// 获取自定义角色-菜单类中的字段名为键,orm中对象的字段名为值的字典 /// /// 自定义角色-菜单类中的字段名为键,orm中对象的字段名为值的字典 public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"ContentId", "contentid"}, {"RoleId", "roleid"}, {"Value", "value"} }; } /// /// 根据ContentRoleEntity的字段转RBACContentRole的字段 /// /// ContentRoleEntity的字段 /// RBACContentRole中的字段 public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取ContentRoleEntity对应的表名 /// /// ContentRoleEntity public static string GetTableName() { return "[dbo].[RBACRoleContent]"; } } }