BaseEntity.cs 868 B

1234567891011121314151617181920212223242526272829303132333435
  1. using SqlSugar;
  2. using System;
  3. namespace SKMC.Api.Common.DB.Entity
  4. {
  5. /// <summary>
  6. /// 基础的Entity模板
  7. /// </summary>
  8. public class BaseEntity
  9. {
  10. [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
  11. public long Id { get; set; }
  12. public string Oper { get; set; }
  13. public DateTime CreateTime { get; set; }
  14. public DateTime UpdateTime { get; set; }
  15. public long Seq { get; set; }
  16. public BaseEntity()
  17. {
  18. if (Id == 0)
  19. {
  20. Id = BitConverter.ToInt64(System.Guid.NewGuid().ToByteArray(), 0);
  21. }
  22. if (Oper == null) Oper = "OP";
  23. if (CreateTime == null) CreateTime = DateTime.Now;
  24. if (UpdateTime == null) UpdateTime = DateTime.Now;
  25. if (Seq == 0) Seq = CreateTime.Ticks;
  26. }
  27. }
  28. }