Blame view

netcore/src/Modularity/Common/NCC.Common/Entity/CLDEntityBase.cs 4 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
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
  using NCC.Common.Const;
  using NCC.Dependency;
  using SqlSugar;
  using System;
  using Yitter.IdGenerator;
  
  namespace NCC.Common.Entity
  {
      /// <summary>
      /// 创更删实体基类
      /// </summary>
      [SuppressSniffer]
      public abstract class CLDEntityBase : EntityBase<string>, ICreatorTime, IDeleteTime
      {
          /// <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>
          [SugarColumn(ColumnName = "F_ENABLEDMARK", ColumnDescription = "启用标识", IsNullable = true)]
          public virtual int? EnabledMark { get; set; }
  
          /// <summary>
          /// 获取或设置 修改时间
          /// </summary>
          [SugarColumn(ColumnName = "F_LastModifyTime", ColumnDescription = "修改时间")]
          public virtual DateTime? LastModifyTime { get; set; }
  
          /// <summary>
          /// 获取或设置 修改用户
          /// </summary>
          [SugarColumn(ColumnName = "F_LastModifyUserId", ColumnDescription = "修改用户")]
          public virtual string LastModifyUserId { get; set; }
  
          /// <summary>
          /// 获取或设置 删除标志
          /// </summary>
          [SugarColumn(ColumnName = "F_DeleteMark", ColumnDescription = "删除标志")]
          public virtual int? DeleteMark { get; set; }
  
          /// <summary>
          /// 获取或设置 删除时间
          /// </summary>
          [SugarColumn(ColumnName = "F_DeleteTime", ColumnDescription = "删除时间", IsNullable = true)]
          public virtual DateTime? DeleteTime { get; set; }
  
          /// <summary>
          /// 获取或设置 删除用户
          /// </summary>
          [SugarColumn(ColumnName = "F_DeleteUserId", ColumnDescription = "删除用户", IsNullable = true)]
          public virtual string DeleteUserId { 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();
              this.EnabledMark = this.EnabledMark == null ? 1 : this.EnabledMark;
              if (!string.IsNullOrEmpty(userId))
              {
                  this.CreatorUserId = userId;
              }
          }
  
          /// <summary>
          /// 创建
          /// </summary>
          public virtual void Create()
          {
              var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
              this.CreatorTime = DateTime.Now;
              this.Id = this.Id == null ? YitIdHelper.NextId().ToString() : this.Id;
              this.EnabledMark = this.EnabledMark == null ? 1 : this.EnabledMark;
              if (!string.IsNullOrEmpty(userId))
              {
                  this.CreatorUserId = CreatorUserId == null ? userId : CreatorUserId;
              }
          }
  
          /// <summary>
          /// 修改
          /// </summary>
          public virtual void LastModify()
          {
              var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
              this.LastModifyTime = DateTime.Now;
              if (!string.IsNullOrEmpty(userId))
              {
                  this.LastModifyUserId = userId;
              }
          }
  
          /// <summary>
          /// 删除
          /// </summary>
          public virtual void Delete()
          {
              var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
              this.DeleteTime = DateTime.Now;
              this.DeleteMark = 1;
              if (!string.IsNullOrEmpty(userId))
              {
                  this.DeleteUserId = userId;
              }
          }
      }
  }