Skip to content

Commit

Permalink
Merge pull request #237 from EasyAbp/add-product-overview
Browse files Browse the repository at this point in the history
Add the `Overview` property to the `Product` entity
  • Loading branch information
gdlcf88 authored Mar 27, 2023
2 parents a5261a9 + ec29b29 commit cb2e466
Show file tree
Hide file tree
Showing 18 changed files with 6,476 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class CreateUpdateProductDto : ExtensibleObject, IMultiStore
[DisplayName("ProductDisplayName")]
public string DisplayName { get; set; }

[DisplayName("ProductOverview")]
public string Overview { get; set; }

public ICollection<CreateUpdateProductAttributeDto> ProductAttributes { get; set; }

[DisplayName("ProductInventoryStrategy")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,50 @@ namespace EasyAbp.EShop.Products.Products.Dtos
public class ProductDto : ExtensibleFullAuditedEntityDto<Guid>
{
public Guid StoreId { get; set; }

public string ProductGroupName { get; set; }

public string ProductGroupDisplayName { get; set; }

public Guid? ProductDetailId { get; set; }

public string UniqueName { get; set; }

public string DisplayName { get; set; }


public string Overview { get; set; }

public InventoryStrategy InventoryStrategy { get; set; }

public string InventoryProviderName { get; set; }

public string MediaResources { get; set; }

public int DisplayOrder { get; set; }

public bool IsPublished { get; set; }

public bool IsStatic { get; set; }

public bool IsHidden { get; set; }

public TimeSpan? PaymentExpireIn { get; set; }

public long Sold { get; set; }

public decimal? MinimumPrice { get; set; }

public decimal? MaximumPrice { get; set; }

public List<ProductAttributeDto> ProductAttributes { get; set; }

public List<ProductSkuDto> ProductSkus { get; set; }

public ProductSkuDto GetSkuById(Guid skuId)
{
return ProductSkus.Single(x => x.Id == skuId);
}

public ProductSkuDto FindSkuById(Guid skuId)
{
return ProductSkus.FirstOrDefault(x => x.Id == skuId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class ProductViewDto : ExtensibleCreationAuditedEntityDto<Guid>

public string DisplayName { get; set; }

public string Overview { get; set; }

public InventoryStrategy InventoryStrategy { get; set; }

public string InventoryProviderName { get; set; }
Expand All @@ -32,9 +34,9 @@ public class ProductViewDto : ExtensibleCreationAuditedEntityDto<Guid>
public bool IsHidden { get; set; }

public decimal? MinimumPrice { get; set; }

public decimal? MaximumPrice { get; set; }

public long Sold { get; set; }

public string ProductGroupDisplayName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ protected override Task<Product> MapToEntityAsync(CreateUpdateProductDto createI
createInput.ProductDetailId,
createInput.UniqueName,
createInput.DisplayName,
createInput.Overview,
createInput.InventoryStrategy,
createInput.InventoryProviderName,
createInput.IsPublished,
Expand All @@ -512,6 +513,7 @@ protected override Task MapToEntityAsync(CreateUpdateProductDto updateInput, Pro
updateInput.ProductDetailId,
updateInput.UniqueName,
updateInput.DisplayName,
updateInput.Overview,
updateInput.InventoryStrategy,
updateInput.InventoryProviderName,
updateInput.IsPublished,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"ProductDetailId": "Product detail ID",
"ProductUniqueName": "Unique name",
"ProductDisplayName": "Display name",
"ProductOverview": "Overview text",
"ProductOverviewPlaceholder": "A one-sentence description of this product, usually displayed in the product list.",
"ProductDisplayOrder": "Display order",
"ProductSold": "Sold",
"ProductDetailDescription": "Description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"ProductDetailId": "商品详情 ID",
"ProductUniqueName": "商品编号",
"ProductDisplayName": "商品名称",
"ProductOverview": "商品文本概述",
"ProductOverviewPlaceholder": "用一句话描述此商品,通常显示于商品列表",
"ProductDisplayOrder": "展示顺序",
"ProductSold": "已售",
"ProductDetailDescription": "详情介绍",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"ProductDetailId": "商品詳情 ID",
"ProductUniqueName": "商品編號",
"ProductDisplayName": "商品名稱",
"ProductOverview": "商品文本概述",
"ProductOverviewPlaceholder": "用一句话描述此商品,通常显示于商品列表",
"ProductDisplayOrder": "展示順序",
"ProductSold": "已售",
"ProductDetailDescription": "詳情介紹",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public interface IProduct : IHasExtraProperties, IMultiStore

string DisplayName { get; }

string Overview { get; }

InventoryStrategy InventoryStrategy { get; }

[CanBeNull] string InventoryProviderName { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ProductEto : ExtensibleObject, IProduct, IMultiTenant

public string DisplayName { get; set; }

public string Overview { get; set; }

public InventoryStrategy InventoryStrategy { get; set; }

public string InventoryProviderName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class Product : FullAuditedAggregateRoot<Guid>, IProduct, IMultiTenant
[NotNull]
public virtual string DisplayName { get; protected set; }

/// <summary>
/// Tell your customer what the product is. It is usually shown in the product list.
/// </summary>
[CanBeNull]
public virtual string Overview { get; protected set; }

public virtual InventoryStrategy InventoryStrategy { get; protected set; }

/// <summary>
Expand Down Expand Up @@ -62,6 +68,7 @@ public Product(
Guid? productDetailId,
[CanBeNull] string uniqueName,
[NotNull] string displayName,
[CanBeNull] string overview,
InventoryStrategy inventoryStrategy,
[CanBeNull] string inventoryProviderName,
bool isPublished,
Expand All @@ -76,6 +83,7 @@ int displayOrder
StoreId = storeId;
ProductGroupName = Check.NotNullOrWhiteSpace(productGroupName, nameof(productGroupName));
ProductDetailId = productDetailId;
Overview = overview;
UniqueName = uniqueName?.Trim();
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName));
InventoryStrategy = inventoryStrategy;
Expand All @@ -97,6 +105,7 @@ public void Update(
Guid? productDetailId,
[CanBeNull] string uniqueName,
[NotNull] string displayName,
[CanBeNull] string overview,
InventoryStrategy inventoryStrategy,
[CanBeNull] string inventoryProviderName,
bool isPublished,
Expand All @@ -111,6 +120,7 @@ public void Update(
ProductDetailId = productDetailId;
UniqueName = uniqueName?.Trim();
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName));
Overview = overview;
InventoryStrategy = inventoryStrategy;
InventoryProviderName = inventoryProviderName;
IsPublished = isPublished;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ProductView : CreationAuditedAggregateRoot<Guid>, IProduct, IMultiT

public virtual string DisplayName { get; protected set; }

public virtual string Overview { get; protected set; }

public virtual InventoryStrategy InventoryStrategy { get; protected set; }

public string InventoryProviderName { get; protected set; }
Expand Down Expand Up @@ -56,6 +58,7 @@ public ProductView(
Guid? productDetailId,
string uniqueName,
string displayName,
string overview,
InventoryStrategy inventoryStrategy,
string inventoryProviderName,
bool isPublished,
Expand All @@ -75,6 +78,7 @@ long sold
ProductDetailId = productDetailId;
UniqueName = uniqueName?.Trim();
DisplayName = displayName;
Overview = overview;
InventoryStrategy = inventoryStrategy;
InventoryProviderName = inventoryProviderName;
IsPublished = isPublished;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CreateEditProductViewModel : IValidatableObject
[HiddenInput]
[Display(Name = "ProductStoreId")]
public Guid StoreId { get; set; }

[Required]
[SelectItems("ProductGroups")]
[Display(Name = "ProductProductGroupName")]
Expand All @@ -30,18 +30,22 @@ public class CreateEditProductViewModel : IValidatableObject

[Display(Name = "ProductUniqueName")]
public string UniqueName { get; set; }

[Required]
[Display(Name = "ProductDisplayName")]
public string DisplayName { get; set; }

[Placeholder("ProductOverviewPlaceholder")]
[Display(Name = "ProductOverview")]
public string Overview { get; set; }

public CreateEditProductDetailViewModel ProductDetail { get; set; } = new();

[Required]
[Placeholder("ProductAttributeNamesPlaceholder")]
[Display(Name = "ProductAttributeNames")]
public string ProductAttributeNames { get; set; }

[Required]
[TextArea(Rows = 4)]
[Placeholder("ProductAttributeOptionNamesPlaceholder")]
Expand All @@ -60,13 +64,13 @@ public class CreateEditProductViewModel : IValidatableObject

[Display(Name = "ProductMediaResources")]
public string MediaResources { get; set; }

[Display(Name = "ProductIsPublished")]
public bool IsPublished { get; set; }

[Display(Name = "ProductIsHidden")]
public bool IsHidden { get; set; }

[Display(Name = "ProductPaymentExpireIn")]
public TimeSpan? PaymentExpireIn { get; set; }

Expand All @@ -76,7 +80,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
{
yield return new ValidationResult(
"The StoreId should be same as the ProductDetail.StoreId.",
new[] {"StoreId"}
new[] { "StoreId" }
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public ProductDomainTests()
public async Task Should_Set_ProductDetailId()
{
var product2 = new Product(ProductsTestData.Product2Id, null, ProductsTestData.Store1Id, "Default",
ProductsTestData.ProductDetails2Id, "Ball", "Ball", InventoryStrategy.NoNeed, null, true, false, false,
null, null, 0);
ProductsTestData.ProductDetails2Id, "Ball", "Ball", null, InventoryStrategy.NoNeed, null, true, false,
false, null, null, 0);
await ProductManager.CreateAsync(product2);

product2 = await ProductRepository.GetAsync(product2.Id);
Expand Down Expand Up @@ -64,8 +64,8 @@ public async Task Should_Reuse_ProductDetail()
product1.ProductDetailId.ShouldBe(ProductsTestData.ProductDetails1Id);

var product2 = new Product(ProductsTestData.Product2Id, null, ProductsTestData.Store1Id, "Default",
ProductsTestData.ProductDetails2Id, "Ball", "Ball", InventoryStrategy.NoNeed, null, true, false, false,
null, null, 0);
ProductsTestData.ProductDetails2Id, "Ball", "Ball", null, InventoryStrategy.NoNeed, null, true, false,
false, null, null, 0);

await ProductManager.CreateAsync(product2);

Expand Down Expand Up @@ -181,7 +181,7 @@ await ProductManager.CreateSkuAsync(product1, await CreateTestSkuAsync(new[]
public async Task Should_Use_Fake_Inventory_Provider()
{
var product2 = new Product(ProductsTestData.Product2Id, null, ProductsTestData.Store1Id, "Default",
ProductsTestData.ProductDetails2Id, "Ball", "Ball", InventoryStrategy.NoNeed, "Fake", true, false,
ProductsTestData.ProductDetails2Id, "Ball", "Ball", null, InventoryStrategy.NoNeed, "Fake", true, false,
false, null, null, 0);

await ProductManager.CreateAsync(product2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ public void Build()
public async Task BuildAsync()
{
using var uow = _unitOfWorkManager.Begin();

var productDetail1 = await _productDetailRepository.InsertAsync(
new ProductDetail(ProductsTestData.ProductDetails1Id, null, ProductsTestData.Store1Id,
"Product details for store 1"), true);

var productDetail2 = await _productDetailRepository.InsertAsync(
new ProductDetail(ProductsTestData.ProductDetails2Id, null, ProductsTestData.Store1Id,
"Product details for store 1"), true);

var product = new Product(ProductsTestData.Product1Id, null, ProductsTestData.Store1Id, "Default",
productDetail1.Id, "Cake", "Cake", InventoryStrategy.NoNeed, null, true, false, false, null, null, 0);
productDetail1.Id, "Cake", "Cake", "Delicious cakes", InventoryStrategy.NoNeed, null, true, false,
false, null, null, 0);

var attribute1 = new ProductAttribute(ProductsTestData.Product1Attribute1Id, "Size", null, 1);
var attribute2 = new ProductAttribute(ProductsTestData.Product1Attribute2Id, "Color", null, 2);
Expand All @@ -57,7 +58,7 @@ public async Task BuildAsync()
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option1Id, "S", null, 1),
new ProductAttributeOption(ProductsTestData.Product1Attribute1Option3Id, "L", null, 3),
});

attribute2.ProductAttributeOptions.AddRange(new[]
{
new ProductAttributeOption(ProductsTestData.Product1Attribute2Option2Id, "Green", null, 2),
Expand All @@ -83,7 +84,7 @@ await _attributeOptionIdsSerializer.SerializeAsync(new[]
await _attributeOptionIdsSerializer.SerializeAsync(new[]
{ ProductsTestData.Product1Attribute1Option3Id, ProductsTestData.Product1Attribute2Option2Id }),
null, "USD", null, 3m, 1, 10, null, null, null);

await _productManager.CreateSkuAsync(product, productSku1);
await _productManager.CreateSkuAsync(product, productSku2);
await _productManager.CreateSkuAsync(product, productSku3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public virtual async Task SeedProductsAsync()
null,
SampleDataConsts.CakeProductUniqueName,
"Cake",
"Delicious cakes",
InventoryStrategy.NoNeed,
null,
true,
Expand Down
Loading

0 comments on commit cb2e466

Please sign in to comment.