feat: 新增规格做法模板管理接口与数据模型
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 45s
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 45s
This commit is contained in:
@@ -201,6 +201,18 @@ public sealed class TakeoutAppDbContext(
|
||||
/// </summary>
|
||||
public DbSet<ProductAttributeOption> ProductAttributeOptions => Set<ProductAttributeOption>();
|
||||
/// <summary>
|
||||
/// 门店规格做法模板。
|
||||
/// </summary>
|
||||
public DbSet<ProductSpecTemplate> ProductSpecTemplates => Set<ProductSpecTemplate>();
|
||||
/// <summary>
|
||||
/// 门店规格做法模板选项。
|
||||
/// </summary>
|
||||
public DbSet<ProductSpecTemplateOption> ProductSpecTemplateOptions => Set<ProductSpecTemplateOption>();
|
||||
/// <summary>
|
||||
/// 门店规格做法模板关联商品。
|
||||
/// </summary>
|
||||
public DbSet<ProductSpecTemplateProduct> ProductSpecTemplateProducts => Set<ProductSpecTemplateProduct>();
|
||||
/// <summary>
|
||||
/// SKU 实体。
|
||||
/// </summary>
|
||||
public DbSet<ProductSku> ProductSkus => Set<ProductSku>();
|
||||
@@ -441,6 +453,9 @@ public sealed class TakeoutAppDbContext(
|
||||
ConfigureProduct(modelBuilder.Entity<Product>());
|
||||
ConfigureProductAttributeGroup(modelBuilder.Entity<ProductAttributeGroup>());
|
||||
ConfigureProductAttributeOption(modelBuilder.Entity<ProductAttributeOption>());
|
||||
ConfigureProductSpecTemplate(modelBuilder.Entity<ProductSpecTemplate>());
|
||||
ConfigureProductSpecTemplateOption(modelBuilder.Entity<ProductSpecTemplateOption>());
|
||||
ConfigureProductSpecTemplateProduct(modelBuilder.Entity<ProductSpecTemplateProduct>());
|
||||
ConfigureProductSku(modelBuilder.Entity<ProductSku>());
|
||||
ConfigureProductAddonGroup(modelBuilder.Entity<ProductAddonGroup>());
|
||||
ConfigureProductAddonOption(modelBuilder.Entity<ProductAddonOption>());
|
||||
@@ -1164,6 +1179,43 @@ public sealed class TakeoutAppDbContext(
|
||||
builder.HasIndex(x => new { x.TenantId, x.AttributeGroupId, x.Name }).IsUnique();
|
||||
}
|
||||
|
||||
private static void ConfigureProductSpecTemplate(EntityTypeBuilder<ProductSpecTemplate> builder)
|
||||
{
|
||||
builder.ToTable("product_spec_templates");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.Name).HasMaxLength(64).IsRequired();
|
||||
builder.Property(x => x.TemplateType).HasConversion<int>();
|
||||
builder.Property(x => x.SelectionType).HasConversion<int>();
|
||||
builder.Property(x => x.SortOrder).IsRequired();
|
||||
builder.Property(x => x.IsEnabled).IsRequired();
|
||||
builder.Property(x => x.IsRequired).IsRequired();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.Name }).IsUnique();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.TemplateType, x.IsEnabled });
|
||||
}
|
||||
|
||||
private static void ConfigureProductSpecTemplateOption(EntityTypeBuilder<ProductSpecTemplateOption> builder)
|
||||
{
|
||||
builder.ToTable("product_spec_template_options");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.TemplateId).IsRequired();
|
||||
builder.Property(x => x.Name).HasMaxLength(64).IsRequired();
|
||||
builder.Property(x => x.ExtraPrice).HasPrecision(18, 2);
|
||||
builder.Property(x => x.SortOrder).IsRequired();
|
||||
builder.HasIndex(x => new { x.TenantId, x.TemplateId, x.Name }).IsUnique();
|
||||
}
|
||||
|
||||
private static void ConfigureProductSpecTemplateProduct(EntityTypeBuilder<ProductSpecTemplateProduct> builder)
|
||||
{
|
||||
builder.ToTable("product_spec_template_products");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.TemplateId).IsRequired();
|
||||
builder.Property(x => x.ProductId).IsRequired();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.TemplateId, x.ProductId }).IsUnique();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ProductId });
|
||||
}
|
||||
|
||||
private static void ConfigureProductSku(EntityTypeBuilder<ProductSku> builder)
|
||||
{
|
||||
builder.ToTable("product_skus");
|
||||
|
||||
Reference in New Issue
Block a user