fix fbs encoding

This commit is contained in:
Aleksandr Trushkin
2024-02-11 20:13:23 +03:00
parent a94cbe6710
commit 23a4f007fc
2 changed files with 14 additions and 6 deletions

View File

@ -88,7 +88,6 @@ func makeDomainGoodItem(builder *flatbuffers.Builder, in entity.GoodsItem) flatb
h = float32(in.Sizes.Height.AdjustTo(entity.DimensionKindCentimeter).Value)
l = float32(in.Sizes.Length.AdjustTo(entity.DimensionKindCentimeter).Value)
}
sizes := CreateDimensions(builder, w, h, l)
GoodItemStart(builder)
GoodItemAddSku(builder, sku)
@ -106,9 +105,9 @@ func makeDomainGoodItem(builder *flatbuffers.Builder, in entity.GoodsItem) flatb
GoodItemAddTariff(builder, float32(in.TariffPrice))
GoodItemAddCart(builder, int64(in.Cart))
GoodItemAddStock(builder, int16(in.Stock))
GoodItemAddSizes(builder, sizes)
GoodItemAddParameters(builder, parameters)
GoodItemAddCreatedAt(builder, in.CreatedAt.Unix())
GoodItemAddSizes(builder, CreateDimensions(builder, w, h, l))
return GoodItemEnd(builder)
}
@ -145,10 +144,13 @@ func ParseGoodsItem(data []byte) (item entity.GoodsItem, err error) {
}
}
var w, h, l float64
sizes := itemFBS.Sizes(nil)
w := float64(sizes.Width())
h := float64(sizes.Height())
l := float64(sizes.Length())
if sizes != nil {
w = float64(sizes.Width())
h = float64(sizes.Height())
l = float64(sizes.Length())
}
item.Sizes = entity.GoodsItemSize{
Width: entity.NewMilimeterDimension(w),