feat(product): add product label management backend
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 43s
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 43s
This commit is contained in:
@@ -213,6 +213,14 @@ public sealed class TakeoutAppDbContext(
|
||||
/// </summary>
|
||||
public DbSet<ProductSpecTemplateProduct> ProductSpecTemplateProducts => Set<ProductSpecTemplateProduct>();
|
||||
/// <summary>
|
||||
/// 商品标签。
|
||||
/// </summary>
|
||||
public DbSet<ProductLabel> ProductLabels => Set<ProductLabel>();
|
||||
/// <summary>
|
||||
/// 标签与商品关联。
|
||||
/// </summary>
|
||||
public DbSet<ProductLabelProduct> ProductLabelProducts => Set<ProductLabelProduct>();
|
||||
/// <summary>
|
||||
/// SKU 实体。
|
||||
/// </summary>
|
||||
public DbSet<ProductSku> ProductSkus => Set<ProductSku>();
|
||||
@@ -456,6 +464,8 @@ public sealed class TakeoutAppDbContext(
|
||||
ConfigureProductSpecTemplate(modelBuilder.Entity<ProductSpecTemplate>());
|
||||
ConfigureProductSpecTemplateOption(modelBuilder.Entity<ProductSpecTemplateOption>());
|
||||
ConfigureProductSpecTemplateProduct(modelBuilder.Entity<ProductSpecTemplateProduct>());
|
||||
ConfigureProductLabel(modelBuilder.Entity<ProductLabel>());
|
||||
ConfigureProductLabelProduct(modelBuilder.Entity<ProductLabelProduct>());
|
||||
ConfigureProductSku(modelBuilder.Entity<ProductSku>());
|
||||
ConfigureProductAddonGroup(modelBuilder.Entity<ProductAddonGroup>());
|
||||
ConfigureProductAddonOption(modelBuilder.Entity<ProductAddonOption>());
|
||||
@@ -1221,6 +1231,30 @@ public sealed class TakeoutAppDbContext(
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ProductId });
|
||||
}
|
||||
|
||||
private static void ConfigureProductLabel(EntityTypeBuilder<ProductLabel> builder)
|
||||
{
|
||||
builder.ToTable("product_labels");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.Name).HasMaxLength(64).IsRequired();
|
||||
builder.Property(x => x.Color).HasMaxLength(32).IsRequired();
|
||||
builder.Property(x => x.SortOrder).IsRequired();
|
||||
builder.Property(x => x.IsEnabled).IsRequired();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.Name }).IsUnique();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.IsEnabled, x.SortOrder });
|
||||
}
|
||||
|
||||
private static void ConfigureProductLabelProduct(EntityTypeBuilder<ProductLabelProduct> builder)
|
||||
{
|
||||
builder.ToTable("product_label_products");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.LabelId).IsRequired();
|
||||
builder.Property(x => x.ProductId).IsRequired();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.LabelId, 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