服务端的TigerApi 框架,基于.NET6 2024 版本
YangYuGang
3 天以前 8ca0a4e167bcfe8ea99efe615c1c0f1bc62255a5
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using SqlSugar;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
namespace Tiger.Model
{
    /// <summary>
    /// 实体:条码规则
    /// </summary>
    [Description("Primary:ID")]
    [Serializable]
    [SugarTable("BAS_CODE_RULE")]
    public class BAS_CODE_RULE : DbEntityWithAuth
    {
        #region 构造函数
        /// <summary>
        /// 实体:条码规则
        /// </summary>
        public BAS_CODE_RULE() { }
        #endregion
 
        #region 公共属性
        /// <summary>
        /// 规则代码(系统自动生成,规则:LK+YYYYMMDD+三位流水码)
        /// </summary>
        public string RULE_CODE { get; set; }
        /// <summary>
        /// 规则名称
        /// </summary>
        public string RULE_NAME { get; set; }
        /// <summary>
        /// 规则描述
        /// </summary>
        public string RULE_DESC { get; set; }
        /// <summary>
        /// 规则类型(0Material物料条码|1SemiProduct半成品条码|2Product成品条码|3BizOrder单据号码)
        /// </summary>
        public int RULE_TYPE { get; set; }
        /// <summary>
        /// 优先级,大于0的整数,越小越优先度越高
        /// </summary>
        public int PRIORITY { get; set; }
        /// <summary>
        /// 是否启用(Y/N)
        /// </summary>
        [DisplayName("是否启用(Y/N)")]
        public string IS_ACTIVE { get; set; }
        /// <summary>
        /// 条码段分隔符
        /// </summary>
        [DisplayName("条码段分隔符")]
        public string SEPARATOR { get; set; }
        /// <summary>
        /// 条码长度
        /// </summary>
        public int CODE_LENGTH { get; set; }
        /// <summary>
        /// 校验类型(0RUL自身校验|1MUL关联校验)
        /// </summary>
        public int CHECK_TYPE { get; set; }
        /// <summary>
        /// 校验表达式
        /// </summary>
        public string CHECK_REGEX { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string REMARK { get; set; }
        #endregion
 
        #region 虚拟属性
        /*例子
        [SugarColumn(IsIgnore = true)]
        public string FieldName { get; set; }
        */
        /// <summary>
        /// Regex 对象, 正则表达式:^(CHECK_REGEX)$
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public Regex Regex => new Regex(Details.Any() ? $"^{string.Concat(Details.OrderBy(q => q.RULE_SEQ).Select(q => q.DATA_REGEX))}$"
                                                                                   : (CHECK_REGEX ?? "").StartsWith("^") ? CHECK_REGEX : $"^{CHECK_REGEX}$");
        /// <summary>
        /// 分组的校验表达式,使用RULE_SEQ分组
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string DATA_REGEX_WithGroup => Details.Any() ? $"^{string.Concat(Details.OrderBy(q => q.RULE_SEQ).Select(q => q.DATA_REGEX_WithGroup))}$" : "";
        /// <summary>
        /// 校验正则表达式
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public Regex GroupRegex => new Regex(DATA_REGEX_WithGroup);
        #endregion
 
        #region 外键属性
        /*例子
        //一对一外键导航
        [Navigate(NavigateType.OneToOne, nameof(ClassAId))]//一对一 ClassAId是BAS_CODE_RULE类里面的外键ID字段
        public ClassA ClassA { get; set; } //注意禁止手动赋值,只能是null
        //一对多外键导航
        [Navigate(NavigateType.OneToMany, nameof(ClassA.BAS_CODE_RULEId))]//ClassA表中的BAS_CODE_RULEId
        public List<ClassA> ClassAList { get; set; }//注意禁止手动赋值,只能是null
        //多对多外键导航
        [Navigate(typeof(MappingClass), nameof(MappingClass.BAS_CODE_RULEId), nameof(MappingClass.ClassAId))]//注意顺序
        public List<ClassA> ClassAList { get; set; } //注意禁止手动赋值,只能是null
        */
        /// <summary>
        /// 包含逻辑删除的数据
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(BAS_CODE_DTL.RULE_ID))]//ClassA表中的BAS_CODE_RULEId
        public List<BAS_CODE_DTL> DetailsWithGhost { get; set; }//注意禁止手动赋值,只能是null
        /// <summary>
        /// 不包含逻辑删除的数据
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<BAS_CODE_DTL> Details => DetailsWithGhost?.Where(q => !q.GHOST_ROW).ToList() ?? new List<BAS_CODE_DTL>();
        [Navigate(NavigateType.OneToMany, nameof(BAS_CODE_GEN.RULE_ID))]//ClassA表中的BAS_CODE_RULEId
        public List<BAS_CODE_GEN> SerialsWithGhost { get; set; }//注意禁止手动赋值,只能是null
        [SugarColumn(IsIgnore = true)]
        public List<BAS_CODE_GEN> Serials => SerialsWithGhost?.Where(q => !q.GHOST_ROW).ToList();
        #endregion
 
        #region 枚举变量
        /// <summary>
        /// 校验类型(0RUL自身校验|1MUL关联校验)
        /// </summary>
        public enum CHECK_TYPEs
        {
            [Description("自身校验")]
            RUL,
            [Description("关联校验")]
            MUL,
        }
        /// <summary>
        /// 规则类型(0Material物料条码|1SemiProduct半成品条码|2Product成品条码|3BizOrder单据号码)
        /// </summary>
        public enum RULE_TYPEs
        {
            [Description("物料条码")]
            Material,
            [Description("半成品条码")]
            SemiProduct,
            [Description("成品条码")]
            Product,
            [Description("单据号码")]
            BizOrder,
        }
        #endregion
 
        #region 公共方法
 
        #endregion
 
    }//endClass
}