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 ContentEntity : ICommonEntity, ITreeEntity
{
///
/// 主键
///
public int Id { get; set; }
///
/// 菜单目录名称
///
public string Name { get; set; }
///
/// 菜单目录备注
///
public string Remark { get; set; }
///
/// 菜单目录访问地址
///
public string Url { get; set; }
///
/// 父菜单Id
///
public int ParentId { get; set; }
///
/// 菜单类型
///
public int Type { get; set; }
///
/// 菜单排序
///
public int ContentIndex { get; set; }
///
/// 菜单图标
///
public string Image { get; set; }
///
/// 子菜单
///
public List Children { get; set; }
///
/// 构造函数
///
public ContentEntity() { }
///
/// 构造函数
///
/// orm中的Content实体
public ContentEntity(RBACContent content)
{
EntityPropHelper.CopyProp(content, this, GetColumnMap());
this.Children = new List();
}
//
/// 将ContentEntity转换成ORM中的实体
///
/// orm中的content实体
public RBACContent ToOrm()
{
var content = new RBACContent();
EntityPropHelper.CopyProp(this, content, GetColumnMap());
return content;
}
///
/// 获取自定义菜单类中的字段名为键,orm中对象的字段名为值的字段
///
///
public static Dictionary GetColumnMap()
{
return new Dictionary()
{
{"Id", "id"},
{"Name", "name"},
{"Remark", "remark"},
{"Url", "url"},
{"ParentId", "parentid"},
{"Type", "type"},
{"ContentIndex", "contentindex"},
{"Image", "image"}
};
}
///
/// 根据ContentEntity的字段转RBAC_Content的字段
///
/// ContentEntity的字段
/// RBAC_Content
public static string GetColumnName(string name)
{
var columnMap = GetColumnMap();
return columnMap.ContainsKey(name) ? columnMap[name] : name;
}
///
/// 获取ContentEntity对于的表名
///
/// RBAC_Content
public static string GetTableName()
{
return "[dbo].[RBACContent]";
}
}
}