using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; using System.Text; namespace APT.Infrastructure.Core { /// /// 实体基类 /// /// 主键类型 public abstract class EntityBase : ICloneable { /// /// 实体基类 /// public EntityBase() { this.FLOW_STATUS = 0;//默认为审核通过 } public Object Clone() { return MemberwiseClone(); } [Description("主键")] public TKey ID { get; set; } [Description("逻辑删除")] public bool IS_DELETED { get; set; } [Description("组织ID")] public Guid? ORG_ID { get; set; } /// /// EntityOrgTypeEnum /// [Description("实体组织类型")] public int ENTITY_ORG_TPYE { get; set; } [Description("窗体模板ID")] public Guid? FORM_ID { get; set; } [Description("审核状态")] public int FLOW_STATUS { get; set; } [Description("送审状态")] public int FLOW_SEND_STATUS { get; set; } [Description("流程ID")] public Guid? FLOW_ID { get; set; } [Description("创建时间")] public System.DateTime? CREATE_TIME { get; set; } [Description("修改时间")] public System.DateTime? MODIFY_TIME { get; set; } //[Description("时间戳")] //public byte[] RowVersion { get; set; } [Description("创建人")] public Guid? CREATER_ID { get; set; } [Description("修改人")] public Guid? MODIFIER_ID { get; set; } [Description("数据库连接")] public string DbConn { get; set; } [Description("组织")] public virtual T_FM_ORGANIZATION Nav_Org { get; set; } [Description("消息ID")] public Guid TaskID { get; set; } /// /// 参数 /// [JsonIgnore] private ParamDynamicDictionary _parmDic = null; [JsonIgnore] [Description("参数")] public dynamic SysParams { get { if (_parmDic == null) { if (this.Nav_SysParams == null) this.Nav_SysParams = new List(); _parmDic = new ParamDynamicDictionary(this.Nav_SysParams, this); } return _parmDic; } } [Description("系统参数")] public virtual List Nav_SysParams { get; set; } } /// /// 主键类型为Guid的实体基类 /// public abstract class MesEntityBase : EntityBase { public MesEntityBase() { this.ID = Guid.NewGuid(); this.IS_DELETED = false; this.CREATE_TIME = DateTime.Now; this.MODIFY_TIME = DateTime.Now; } public virtual string ToString() { StringBuilder sb = new StringBuilder(""); sb.Append("{"); Type type = this.GetType(); PropertyInfo[] properties = type.GetProperties( BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { object propertyValue = property.GetValue(this, null); sb.Append("\""); sb.Append(property.Name); sb.Append("\":"); if (propertyValue != null) { sb.Append(propertyValue.ToString()); } else { sb.Append(""); } sb.AppendLine(""); } sb.Append("}"); return sb.ToString(); } } /// /// int型主键基类 /// public abstract class MesIntEntityBase : EntityBase { public MesIntEntityBase() { this.IS_DELETED = false; this.CREATE_TIME = DateTime.Now; this.MODIFY_TIME = DateTime.Now; } public virtual string ToString() { StringBuilder sb = new StringBuilder(""); sb.Append("{"); Type type = this.GetType(); PropertyInfo[] properties = type.GetProperties( BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { object propertyValue = property.GetValue(this, null); sb.Append("\""); sb.Append(property.Name); sb.Append("\":"); if (propertyValue != null) { sb.Append(propertyValue.ToString()); } else { sb.Append(""); } sb.AppendLine(""); } sb.Append("}"); return sb.ToString(); } } /// /// int型主键的树形表基类 /// public abstract class MesTreeIntEntityBase : MesIntEntityBase { /// /// 父级ID /// [Description("父级ID")] public Guid? PARENT_ID { get; set; } /// /// 显示名称 /// [Description("显示")] public string TEXT { get; set; } } /// /// GUID主键的树形表基类 /// public abstract class MesTreeEntityBase : MesEntityBase { public MesTreeEntityBase() { this.IS_LEAF = true; } /// /// 父级ID /// [Description("父级ID")] public Guid? PARENT_ID { get; set; } /// /// 显示名称 /// [Description("父级ID")] public string TEXT { get; set; } /// /// 是否叶子节点 /// [Description("是否叶子节点")] public bool IS_LEAF { get; set; } } public abstract class TreeEntityBase : MesTreeEntityBase { [Description("父节点")] public virtual T Nav_Parent { get; set; } [Description("子节点")] public virtual ICollection Nav_Children { get; set; } } /// /// 审核 /// public abstract class AuditMesEntityBase : MesEntityBase { #region /// /// 审核状态 /// [Description("审核状态")] public int AUDIT_STATUS { get; set; } /// /// 当前审批子节点ID /// [Description("当前审批子节点")] public Guid? NODE_CHILD_ID { get; set; } /// /// 当前审批节点ID /// [Description("当前审批节点ID")] public Guid? AUDIT_NODE_ID { get; set; } /// /// 审批流ID /// [Description("审批流ID")] public Guid? AUDIT_FLOW_ID { get; set; } #endregion } public abstract class EntityBase : EntityBase { /// /// 构造函数 /// public EntityBase() { this.ID = Guid.NewGuid(); this.IS_DELETED = false; this.CREATE_TIME = DateTime.Now; this.MODIFY_TIME = DateTime.Now; } public virtual string ToString() { StringBuilder sb = new StringBuilder(""); sb.Append("{"); Type type = this.GetType(); PropertyInfo[] properties = type.GetProperties( BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { object propertyValue = property.GetValue(this, null); sb.Append("\""); sb.Append(property.Name); sb.Append("\":"); if (propertyValue != null) { sb.Append(propertyValue.ToString()); } else { sb.Append(""); } sb.AppendLine(""); } sb.Append("}"); return sb.ToString(); } } /// /// 包含部门ID的实体接口 /// public interface IDepartmentEntity { /// /// 部门ID /// Guid DEPARTMENT_ID { get; set; } } }