schangxiang@126.com
2025-05-08 9cc9187d1d56332ab06620ae5bce8a9d0d2045bd
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
using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
 
namespace CMS.Plugin.WareCmsUtilityApi.Domain.Samples
{
    /// <summary>
    /// Sample
    /// </summary>
    public class Sample : FullAuditedAggregateRoot<Guid>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Sample"/> class.
        /// </summary>
        protected Sample()
        {
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="Sample"/> class.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="code">The code.</param>
        /// <param name="name">The name.</param>
        /// <param name="sort">The sort.</param>
        /// <param name="remark">The remark.</param>
        public Sample(Guid id, string code, string name, int sort = 0, string remark = null) : base(id)
        {
            Code = Check.NotNullOrWhiteSpace(code, "编号", SampleConsts.MaxCodeLength);
            Name = Check.NotNullOrWhiteSpace(name, "名称", SampleConsts.MaxNameLength);
            Sort = sort;
            Remark = Check.Length(remark, "备注", SampleConsts.MaxRemarkLength);
        }
 
        /// <summary>
        /// 编号
        /// </summary>
        public virtual string Code { get; protected set; }
 
        /// <summary>
        /// 名称
        /// </summary>
        public virtual string Name { get; protected set; }
 
        /// <summary>
        /// 排序
        /// </summary>
        public virtual int Sort { get; protected set; }
 
        /// <summary>
        /// 备注
        /// </summary>
        public virtual string Remark { get; protected set; }
 
        /// <summary>
        /// 是否禁用
        /// </summary>
        public virtual bool? IsDisabled { get; protected set; }
 
        /// <summary>
        /// Updates the specified code.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="name">The name.</param>
        /// <param name="remark">The remark.</param>
        public virtual void Update(string code, string name, string remark = null, bool? isDisabled = null)
        {
            Code = Check.NotNullOrWhiteSpace(code, "编号", SampleConsts.MaxCodeLength);
            Name = Check.NotNullOrWhiteSpace(name, "名称", SampleConsts.MaxNameLength);
            Remark = Check.Length(remark, "备注", SampleConsts.MaxRemarkLength);
            IsDisabled = isDisabled ?? IsDisabled;
        }
 
        /// <summary>
        /// Adjusts the sort.
        /// </summary>
        /// <param name="sort">The sort.</param>
        public void AdjustSort(int sort)
        {
            Sort = sort;
        }
 
        /// <summary>
        /// Clones the specified create.
        /// </summary>
        /// <param name="create">The create.</param>
        /// <param name="name">The name.</param>
        /// <param name="i">The i.</param>
        /// <returns></returns>
        public Sample Clone(Guid create, string name, int i)
        {
            return new Sample(create, Code, name, i, Remark);
        }
    }
}