Blame view

netcore/src/Modularity/Common/NCC.Common/Entity/CEntityBase.cs 1.17 KB
de2bd2f9   “wangming”   项目初始化
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
  using NCC.Common.Const;
  using NCC.Dependency;
  using SqlSugar;
  using System;
  using Yitter.IdGenerator;
  
  namespace NCC.Common.Entity
  {
      /// <summary>
      /// 创实体基类
      /// </summary>
      [SuppressSniffer]
      public abstract class CEntityBase : EntityBase<string>, ICreatorTime
      {
          /// <summary>
          /// 获取或设置 创建时间
          /// </summary>
          [SugarColumn(ColumnName = "F_CREATORTIME", ColumnDescription = "创建时间")]
          public virtual DateTime? CreatorTime { get; set; }
  
          /// <summary>
          /// 获取或设置 创建用户
          /// </summary>
          [SugarColumn(ColumnName = "F_CREATORUSERID", ColumnDescription = "创建用户")]
          public virtual string CreatorUserId { get; set; }
  
          /// <summary>
          /// 创建
          /// </summary>
          public virtual void Creator()
          {
              var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
              this.CreatorTime = DateTime.Now;
              this.Id = YitIdHelper.NextId().ToString();
              if (!string.IsNullOrEmpty(userId))
              {
                  this.CreatorUserId = userId;
              }
          }
      }
  }