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