Files
Atomx/Atomx.Admin/Atomx.Admin.Client/Models/ProductSkuModel.cs
2025-12-02 13:10:10 +08:00

78 lines
2.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Atomx.Utils.Extension;
namespace Atomx.Admin.Client.Models
{
/// <summary>
/// 产品SKU信息模型
/// </summary>
public class ProductSkuModel : IEquatable<ProductSkuModel>
{
/// <summary>
/// 属性ID
/// </summary>
public long AttributeId { get; set; }
/// <summary>
/// 属性名称
/// </summary>
public string AttributeName { get; set; } = string.Empty;
/// <summary>
/// 属性值ID
/// </summary>
public long ValueId { get; set; }
/// <summary>
/// 属性值 Name
/// </summary>
public string ValueName { get; set; } = string.Empty;
/// <summary>
/// 重量
/// </summary>
public decimal Weight { get; set; }
/// <summary>
/// 重量单位,1毫克mg2克g,3千克kg,4吨t5磅lb6盎司oz
/// </summary>
public int WeightUnit { get; set; }
public bool Equals(ProductSkuModel? other)
{
if (other is null) return false;
if (ValueId != other.ValueId)
{
return AttributeId == other.AttributeId &&
ValueId == other.ValueId &&
Weight.RemoveTrailingZeros() == other.Weight.RemoveTrailingZeros() &&
WeightUnit == other.WeightUnit &&
AttributeName == other.AttributeName &&
ValueName == other.ValueName;
}
else
{
return AttributeId == other.AttributeId &&
ValueId == other.ValueId &&
AttributeName == other.AttributeName;
}
}
public override bool Equals(object obj) => Equals(obj as ProductSkuModel);
public override int GetHashCode()
{
unchecked
{
int hash = 17;
hash = hash * 23 + AttributeId.GetHashCode();
hash = hash * 23 + ValueId.GetHashCode();
hash = hash * 23 + Weight.GetHashCode();
hash = hash * 23 + WeightUnit.GetHashCode();
hash = hash * 23 + (AttributeName?.GetHashCode() ?? 0);
hash = hash * 23 + (ValueName?.GetHashCode() ?? 0);
return hash;
}
}
}
}