Разбить Infrastructure и корень Deal.Api по назначению
Integrations -> Abstractions/Exceptions/Extensions/Models/Options/ Services (включая Storage); Persistence-конфигурации -> Configurations; корень Deal.Api (оркестратор/планировщики/DTO) -> Services/Dtos. namespace приведён к путям, using добавлены/дедуплицированы, FQN обновлены.
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
using Deal.Infrastructure.Persistence.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Deal.Infrastructure.Persistence;
|
||||
using Deal.Infrastructure.Persistence.Configurations;
|
||||
|
||||
namespace Deal.Infrastructure.Persistence.Configurations;
|
||||
|
||||
/// <summary>
|
||||
/// EF-конфигурация события расхода токенов: таблица token_usage_events в схеме public (append-only).
|
||||
/// </summary>
|
||||
public sealed class TokenUsageEventConfiguration : IEntityTypeConfiguration<TokenUsageEventEntity>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<TokenUsageEventEntity> builder)
|
||||
{
|
||||
builder.ToTable("token_usage_events", "public");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
|
||||
builder.Property(x => x.TenantId).IsRequired();
|
||||
builder.Property(x => x.At).IsRequired();
|
||||
builder.Property(x => x.Provider).IsRequired();
|
||||
builder.Property(x => x.Model).IsRequired();
|
||||
builder.Property(x => x.Kind).IsRequired();
|
||||
builder.Property(x => x.PromptTokens).IsRequired();
|
||||
builder.Property(x => x.CompletionTokens).IsRequired();
|
||||
builder.Property(x => x.TotalTokens).IsRequired();
|
||||
builder.Property(x => x.DetailJson).HasColumnType("text");
|
||||
|
||||
builder.HasIndex(x => new { x.TenantId, x.At });
|
||||
builder.HasIndex(x => x.At);
|
||||
|
||||
builder.HasOne<TenantEntity>()
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.TenantId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user