schangxiang@126.com
2025-09-17 ab9d9126ced7d6dac0e14c3ede5a49fdb7fc94df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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]";
        }
    }
}