Skip to content

Commit

Permalink
reactor : Unified constant naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 committed Jul 31, 2023
1 parent e80b9a7 commit 02a3f97
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Domain/Masa.Alert.Domain.Shared/Consts/AlertConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Masa.Alert.Domain.Shared.Consts;

public static class AlertConsts
{
public const string DbTablePrefix = null;
public const string DbSchema = "alert";
public const string DB_TABLE_PREFIX = null;
public const string DB_SCHEMA = "alert";
public const string ALARM_RULE_NAME_NOTIFICATION_TEMPLATE_VAR_NAME = "Name";
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void OnModelCreatingExecuting(ModelBuilder builder)
{
builder.Entity<AlarmRuleQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmRules", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmRules", AlertConsts.DB_SCHEMA);
b.HasMany(x => x.LogMonitorItems).WithOne().HasForeignKey(x => x.AlarmRuleId).IsRequired();
b.HasMany(x => x.MetricMonitorItems).WithOne().HasForeignKey(x => x.AlarmRuleId).IsRequired();
b.HasMany(x => x.Items).WithOne().HasForeignKey(x => x.AlarmRuleId).IsRequired();
Expand Down Expand Up @@ -50,14 +50,14 @@ protected override void OnModelCreatingExecuting(ModelBuilder builder)

builder.Entity<AlarmRuleRecordQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmRuleRecords", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleRecords", AlertConsts.DB_SCHEMA);
b.Property(x => x.AggregateResult).HasConversion(new JsonValueConverter<ConcurrentDictionary<string, long>>());
b.Property(x => x.RuleResultItems).HasConversion(new JsonValueConverter<List<RuleResultItemQueryModel>>());
});

builder.Entity<AlarmHistoryQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmHistorys", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmHistorys", AlertConsts.DB_SCHEMA);
b.HasOne(x => x.AlarmRule);
b.Property(x => x.HandleNotificationConfig).HasConversion(new JsonValueConverter<NotificationConfigQueryModel>());
b.Property(x => x.RuleResultItems).HasConversion(new JsonValueConverter<List<RuleResultItemQueryModel>>());
Expand All @@ -66,12 +66,12 @@ protected override void OnModelCreatingExecuting(ModelBuilder builder)

builder.Entity<LogMonitorItemQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmRuleLogMonitors", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleLogMonitors", AlertConsts.DB_SCHEMA);
});

builder.Entity<MetricMonitorItemQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmRuleMetricMonitors", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleMetricMonitors", AlertConsts.DB_SCHEMA);
b.OwnsOne(x => x.Aggregation, b =>
{
b.Property(x => x.Name).HasColumnName("Name");
Expand All @@ -84,19 +84,19 @@ protected override void OnModelCreatingExecuting(ModelBuilder builder)

builder.Entity<AlarmRuleItemQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmRuleItems", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleItems", AlertConsts.DB_SCHEMA);
b.Property(x => x.RecoveryNotificationConfig).HasConversion(new JsonValueConverter<NotificationConfigQueryModel>());
b.Property(x => x.NotificationConfig).HasConversion(new JsonValueConverter<NotificationConfigQueryModel>());
});

builder.Entity<AlarmHandleStatusCommitQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "AlarmHandleStatusCommits", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "AlarmHandleStatusCommits", AlertConsts.DB_SCHEMA);
});

builder.Entity<WebHookQueryModel>(b =>
{
b.ToView(AlertConsts.DbTablePrefix + "WebHooks", AlertConsts.DbSchema);
b.ToView(AlertConsts.DB_TABLE_PREFIX + "WebHooks", AlertConsts.DB_SCHEMA);
});

base.OnModelCreatingExecuting(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class AlarmHistoryConfiguration : IEntityTypeConfiguration<AlarmHistory>
{
public void Configure(EntityTypeBuilder<AlarmHistory> builder)
{
builder.ToTable(AlertConsts.DbTablePrefix + "AlarmHistorys", AlertConsts.DbSchema);
builder.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmHistorys", AlertConsts.DB_SCHEMA);
builder.Property(x => x.RuleResultItems).HasConversion(new JsonValueConverter<List<RuleResultItem>>());
builder.OwnsMany(x => x.HandleStatusCommits, b =>
{
b.ToTable(AlertConsts.DbTablePrefix + "AlarmHandleStatusCommits", AlertConsts.DbSchema);
b.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmHandleStatusCommits", AlertConsts.DB_SCHEMA);
b.Property<Guid>("Id").ValueGeneratedOnAdd();
b.HasKey("Id");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ public class AlarmRuleConfiguration : IEntityTypeConfiguration<AlarmRule>
{
public void Configure(EntityTypeBuilder<AlarmRule> builder)
{
builder.ToTable(AlertConsts.DbTablePrefix + "AlarmRules", AlertConsts.DbSchema);
builder.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmRules", AlertConsts.DB_SCHEMA);
builder.Property(x => x.DisplayName).IsRequired().HasMaxLength(128);
builder.Property(x => x.ProjectIdentity).HasMaxLength(128);
builder.Property(x => x.AppIdentity).HasMaxLength(128);
builder.Property(x => x.ChartYAxisUnit).HasMaxLength(128);
builder.Property(x => x.TotalVariable).HasMaxLength(64);
builder.OwnsMany(x => x.LogMonitorItems, b =>
{
b.ToTable(AlertConsts.DbTablePrefix + "AlarmRuleLogMonitors", AlertConsts.DbSchema);
b.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleLogMonitors", AlertConsts.DB_SCHEMA);
b.Property<Guid>("Id").ValueGeneratedOnAdd();
b.HasKey("Id");
b.Property(x => x.AggregationType).HasConversion(v => v.Id, v => Enumeration.FromValue<Domain.AlarmRules.LogAggregationType>(v));
});
builder.OwnsMany(x => x.MetricMonitorItems, b =>
{
b.ToTable(AlertConsts.DbTablePrefix + "AlarmRuleMetricMonitors", AlertConsts.DbSchema);
b.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleMetricMonitors", AlertConsts.DB_SCHEMA);
b.Property<Guid>("Id").ValueGeneratedOnAdd();
b.HasKey("Id");
b.OwnsOne(x => x.Aggregation, b =>
Expand All @@ -36,7 +36,7 @@ public void Configure(EntityTypeBuilder<AlarmRule> builder)
});
builder.OwnsMany(x => x.Items, b =>
{
b.ToTable(AlertConsts.DbTablePrefix + "AlarmRuleItems", AlertConsts.DbSchema);
b.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleItems", AlertConsts.DB_SCHEMA);
b.Property<Guid>("Id").ValueGeneratedOnAdd();
b.HasKey("Id");
b.Property(x => x.RecoveryNotificationConfig).HasConversion(new JsonValueConverter<NotificationConfig>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AlarmRuleRecordConfiguration : IEntityTypeConfiguration<AlarmRuleRe
{
public void Configure(EntityTypeBuilder<AlarmRuleRecord> builder)
{
builder.ToTable(AlertConsts.DbTablePrefix + "AlarmRuleRecords", AlertConsts.DbSchema);
builder.ToTable(AlertConsts.DB_TABLE_PREFIX + "AlarmRuleRecords", AlertConsts.DB_SCHEMA);
builder.Property(x => x.AggregateResult).HasConversion(new JsonValueConverter<ConcurrentDictionary<string, long>>());
builder.Property(x => x.RuleResultItems).HasConversion(new JsonValueConverter<List<RuleResultItem>>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class WebHookConfiguration : IEntityTypeConfiguration<WebHook>
{
public void Configure(EntityTypeBuilder<WebHook> builder)
{
builder.ToTable(AlertConsts.DbTablePrefix + "WebHooks", AlertConsts.DbSchema);
builder.ToTable(AlertConsts.DB_TABLE_PREFIX + "WebHooks", AlertConsts.DB_SCHEMA);
}
}

0 comments on commit 02a3f97

Please sign in to comment.