using Atomx.Utils.Extension;
namespace Atomx.Admin.Client.Models
{
///
/// 产品SKU信息模型
///
public class ProductSkuModel : IEquatable
{
///
/// 属性ID
///
public long AttributeId { get; set; }
///
/// 属性名称
///
public string AttributeName { get; set; } = string.Empty;
///
/// 属性值ID
///
public long ValueId { get; set; }
///
/// 属性值 Name
///
public string ValueName { get; set; } = string.Empty;
///
/// 重量
///
public decimal Weight { get; set; }
///
/// 重量单位,1毫克mg,2克g,3千克kg,4吨t,5磅lb,6盎司oz
///
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;
}
}
}
}