track/src/TrackCenter.Domain/Aggregates/WarningAggregate/WarningRuleEntity.cs
2025-09-02 15:32:49 +08:00

67 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Fake.Domain.Entities.Auditing;
using TrackCenter.Domain.Extensions;
namespace TrackCenter.Domain.Aggregates.WarningAggregate;
// 预警规则主体
[SugarTable("t_warning", TableDescription = "预警规则主体")]
[SugarIndex("IDX_Customer_AppKey", nameof(Customer), OrderByType.Asc, nameof(AppKey), OrderByType.Asc)]
public sealed class WarningRuleEntity : FullAuditedAggregateRoot<int, int>
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
[SugarColumn(ColumnName = "AppKey", ColumnDescription = "应用")]
public string AppKey { get; set; } //应用
[SugarColumn(ColumnName = "Customer", ColumnDescription = "客户")]
public string Customer { get; set; } //客户
// [SugarColumn(ColumnName = "CustomName", ColumnDescription = "客户名称")]
// public string CustomName { get; set; } //冗余客户简称,用于查询
[SugarColumn(ColumnName = "Name", ColumnDescription = "预警规则名称")]
public string Name { get; set; } //预警规则名称
[SugarColumn(ColumnName = "IsEnabled", ColumnDescription = "是否启用")]
public bool IsEnabled { get; set; }
[SugarColumn(ColumnName = "WarningType", ColumnDescription = "预警类型,1:运输时效,2:回传时效,3:完整预警")]
public int WarningType { get; set; } //预警类型,1:运输时效,2:回传时效,3:完整预警
[SugarColumn(ColumnName = "Version", ColumnDescription = "规则版本,用于标识规则产物(如预警信息)")]
public string Version { get; set; } //规则版本,用于标识规则产物(如预警信息)
public WarningRuleEntity()
{
}
public WarningRuleEntity(int id, string name, string appKey, string customer, bool isEnabled, int warningType, string version)
{
Id = id;
Name = name;
AppKey = appKey;
Customer = customer;
IsEnabled = isEnabled;
WarningType = warningType;
Version = version;
}
public WarningRuleEntity(int id, string name, string appKey, string customer, bool isEnabled, int warningType)
{
Id = id;
Name = name;
AppKey = appKey;
Customer = customer;
IsEnabled = isEnabled;
WarningType = warningType;
Version = VersionGenerate.GenVersion();
}
// 应用+客户id确定命中规则主体
public bool CanHitRule(string appKey, string customer)
{
return AppKey == appKey && Customer == customer;
}
}