Created Author, Book, AuthorBook, Page and Product with Price
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Products.Entities;
|
||||
|
||||
[EntityTypeConfiguration<ProductConfiguration, Product>]
|
||||
public class Product : Models.Product
|
||||
{
|
||||
public virtual ICollection<ProductPrice> Prices { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Products.Entities;
|
||||
|
||||
public class ProductConfiguration : IEntityTypeConfiguration<Product>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Product> builder)
|
||||
{
|
||||
builder.ToTable("Products");
|
||||
|
||||
builder.HasKey(f => f.Id);
|
||||
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.UpdatedAt).HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.Type).IsRequired();
|
||||
builder.Property(f => f.Name).IsRequired().HasMaxLength(255);
|
||||
builder.Property(f => f.Summary).IsRequired().HasMaxLength(512);
|
||||
builder.Property(f => f.Description).HasMaxLength(1024);
|
||||
builder.Property(f => f.ImageUrl).HasMaxLength(1024);
|
||||
builder.Property(f => f.ThumbnailUrls).IsRequired(false).HasColumnType("jsonb");
|
||||
builder.Property(f => f.Metadata).IsRequired(false).HasColumnType("jsonb");
|
||||
builder.Property(f => f.Categories).IsRequired(false).HasColumnType("jsonb");
|
||||
builder.Property(f => f.Enabled).HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Products.Entities;
|
||||
|
||||
[EntityTypeConfiguration<ProductPriceConfiguration, ProductPrice>]
|
||||
public class ProductPrice : Models.ProductPrice
|
||||
{
|
||||
public virtual Product Product { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Products.Entities;
|
||||
|
||||
public class ProductPriceConfiguration : IEntityTypeConfiguration<ProductPrice>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ProductPrice> builder)
|
||||
{
|
||||
builder.ToTable("Prices");
|
||||
|
||||
builder.HasKey(f => f.Id);
|
||||
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.UpdatedAt).HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.ProductId).IsRequired();
|
||||
builder.Property(f => f.Amount).IsRequired().HasPrecision(18, 2);
|
||||
builder.Property(f => f.Discount).IsRequired().HasPrecision(18, 2);
|
||||
builder.Property(f => f.Enabled).HasDefaultValue(false);
|
||||
|
||||
builder.HasOne(f => f.Product)
|
||||
.WithMany(p => p.Prices)
|
||||
.HasForeignKey(f => f.ProductId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user