feat(product): add product schedule management api
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 46s
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 46s
This commit is contained in:
@@ -221,6 +221,14 @@ public sealed class TakeoutAppDbContext(
|
||||
/// </summary>
|
||||
public DbSet<ProductLabelProduct> ProductLabelProducts => Set<ProductLabelProduct>();
|
||||
/// <summary>
|
||||
/// 商品时段规则。
|
||||
/// </summary>
|
||||
public DbSet<ProductSchedule> ProductSchedules => Set<ProductSchedule>();
|
||||
/// <summary>
|
||||
/// 时段规则与商品关联。
|
||||
/// </summary>
|
||||
public DbSet<ProductScheduleProduct> ProductScheduleProducts => Set<ProductScheduleProduct>();
|
||||
/// <summary>
|
||||
/// SKU 实体。
|
||||
/// </summary>
|
||||
public DbSet<ProductSku> ProductSkus => Set<ProductSku>();
|
||||
@@ -466,6 +474,8 @@ public sealed class TakeoutAppDbContext(
|
||||
ConfigureProductSpecTemplateProduct(modelBuilder.Entity<ProductSpecTemplateProduct>());
|
||||
ConfigureProductLabel(modelBuilder.Entity<ProductLabel>());
|
||||
ConfigureProductLabelProduct(modelBuilder.Entity<ProductLabelProduct>());
|
||||
ConfigureProductSchedule(modelBuilder.Entity<ProductSchedule>());
|
||||
ConfigureProductScheduleProduct(modelBuilder.Entity<ProductScheduleProduct>());
|
||||
ConfigureProductSku(modelBuilder.Entity<ProductSku>());
|
||||
ConfigureProductAddonGroup(modelBuilder.Entity<ProductAddonGroup>());
|
||||
ConfigureProductAddonOption(modelBuilder.Entity<ProductAddonOption>());
|
||||
@@ -1255,6 +1265,31 @@ public sealed class TakeoutAppDbContext(
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ProductId });
|
||||
}
|
||||
|
||||
private static void ConfigureProductSchedule(EntityTypeBuilder<ProductSchedule> builder)
|
||||
{
|
||||
builder.ToTable("product_schedules");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.Name).HasMaxLength(64).IsRequired();
|
||||
builder.Property(x => x.StartTime).IsRequired();
|
||||
builder.Property(x => x.EndTime).IsRequired();
|
||||
builder.Property(x => x.WeekDaysMask).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 });
|
||||
}
|
||||
|
||||
private static void ConfigureProductScheduleProduct(EntityTypeBuilder<ProductScheduleProduct> builder)
|
||||
{
|
||||
builder.ToTable("product_schedule_products");
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.Property(x => x.StoreId).IsRequired();
|
||||
builder.Property(x => x.ScheduleId).IsRequired();
|
||||
builder.Property(x => x.ProductId).IsRequired();
|
||||
builder.HasIndex(x => new { x.TenantId, x.StoreId, x.ScheduleId, 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