DEntityBase.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Furion.DatabaseAccessor;
  2. using Microsoft.EntityFrameworkCore;
  3. using System;
  4. using System.ComponentModel.DataAnnotations;
  5. using System.ComponentModel.DataAnnotations.Schema;
  6. using System.Text.Json.Serialization;
  7. namespace YBEE.EQM.Core
  8. {
  9. /// <summary>
  10. /// 自定义实体基类
  11. /// </summary>
  12. public abstract class DEntityBase : DEntityBase<int, MasterDbContextLocator>
  13. {
  14. }
  15. public abstract class DEntityBase<TKey> : DEntityBase<TKey, MasterDbContextLocator>
  16. {
  17. }
  18. public abstract class DEntityBase<TKey, TDbContextLocator1> : PrivateDEntityBase<TKey> where TDbContextLocator1 : class, IDbContextLocator
  19. {
  20. }
  21. public abstract class PrivateDEntityBase<TKey> : IPrivateEntity
  22. {
  23. /// <summary>
  24. /// 主键
  25. /// </summary>
  26. [Comment("主键")]
  27. [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  28. public virtual TKey Id { get; set; }
  29. /// <summary>
  30. /// 创建时间
  31. /// </summary>
  32. [Comment("创建时间")]
  33. [Required]
  34. public virtual DateTime CreateTime { get; set; }
  35. /// <summary>
  36. /// 更新时间
  37. /// </summary>
  38. [Comment("更新时间")]
  39. public virtual DateTime? UpdateTime { get; set; }
  40. /// <summary>
  41. /// 创建人ID
  42. /// </summary>
  43. [Comment("创建人ID")]
  44. [Required]
  45. public virtual int CreateSysUserId { get; set; }
  46. /// <summary>
  47. /// 修改者Id
  48. /// </summary>
  49. [Comment("修改者Id")]
  50. public virtual int? UpdateSysUserId { get; set; }
  51. /// <summary>
  52. /// 软删除
  53. /// </summary>
  54. [Comment("软删除标记")]
  55. [Required, JsonIgnore]
  56. public virtual bool IsDeleted { get; set; } = false;
  57. /// <summary>
  58. /// 一对一引用(创建人)
  59. /// </summary>
  60. public virtual SysUser CreateSysUser { get; set; }
  61. /// <summary>
  62. /// 一对一引用(更新人)
  63. /// </summary>
  64. public virtual SysUser UpdateSysUser { get; set; }
  65. }
  66. }