payne
2024-04-25 bf915c71f7ab3fcd9a7f81ed18f3a10c68d50dc0
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
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
 
namespace Admin.NET.Core
{
    /// <summary>
    /// 自定义实体基类
    /// </summary>
    public abstract class DEntityBase : DEntityBase<long, MasterDbContextLocator>
    {
        public DEntityBase()
        {
            Id = Yitter.IdGenerator.YitIdHelper.NextId();
        }
    }
 
    public abstract class DEntityBase<TKey, TDbContextLocator1> : PrivateDEntityBase<TKey>
        where TDbContextLocator1 : class, IDbContextLocator
    {
    }
 
    public abstract class PrivateDEntityBase<TKey> : IPrivateEntity
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Comment("Id主键")]
        public virtual TKey Id { get; set; }
 
        /// <summary>
        /// 创建时间
        /// </summary>
        [Comment("创建时间")]
        public virtual DateTimeOffset? CreatedTime { get; set; } = DateTime.Now;
 
        /// <summary>
        /// 更新时间
        /// </summary>
        [Comment("更新时间")]
        public virtual DateTimeOffset? UpdatedTime { get; set; } = DateTime.Now;
 
        /// <summary>
        /// 创建者Id
        /// </summary>
        [Comment("创建者Id")]
        public virtual long? CreatedUserId { get; set; }
 
        /// <summary>
        /// 创建者名称
        /// </summary>
        [Comment("创建者名称")]
        [MaxLength(50)]
        public virtual string CreatedUserName { get; set; }
 
        /// <summary>
        /// 修改者Id
        /// </summary>
        [Comment("修改者Id")]
        public virtual long? UpdatedUserId { get; set; }
 
        /// <summary>
        /// 修改者名称
        /// </summary>
        [Comment("修改者名称")]
        [MaxLength(50)]
        public virtual string UpdatedUserName { get; set; }
 
 
        /// <summary>
        /// 软删除
        /// </summary>
        [JsonIgnore]
        [Comment("软删除标记")]
        public virtual bool IsDeleted { get; set; } = false;
    }
}