feat: sizes shit
This commit is contained in:
@@ -1,28 +1,36 @@
|
||||
package mapping
|
||||
|
||||
import wbclient "sipro-mps/pkg/api/wb/client"
|
||||
import (
|
||||
proto "sipro-mps/api/generated/v1/wb/products"
|
||||
internal "sipro-mps/pkg/api/wb/client"
|
||||
wbclient "sipro-mps/pkg/api/wb/client"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/jmattheis/goverter/cmd/goverter gen .
|
||||
|
||||
// goverter:converter
|
||||
// goverter:extend OptIntToInt64 OptStringToString WbDimensionsToProto
|
||||
// goverter:ignoreUnexported yes
|
||||
// goverter:matchIgnoreCase yes
|
||||
type Converter interface {
|
||||
ToProto(details *internal.ContentV2GetCardsListPostOKCardsItem) *proto.Product
|
||||
}
|
||||
|
||||
// import (
|
||||
//
|
||||
// proto "sipro-mps/api/generated/v1/wb/products"
|
||||
// internal "sipro-mps/internal/wb/products"
|
||||
// wbclient "sipro-mps/pkg/api/wb/client"
|
||||
//
|
||||
// )
|
||||
//
|
||||
// //go:generate go run github.com/jmattheis/goverter/cmd/goverter gen -global "ignoreUnexported yes" .
|
||||
//
|
||||
// // goverter:converter
|
||||
// // goverter:extend OptIntToInt64 OptStringToString
|
||||
//
|
||||
// type Converter interface {
|
||||
// // goverter:ignore state sizeCache unknownFields
|
||||
//
|
||||
// ToProto(details *internal.WbProduct) *proto.Product
|
||||
// }
|
||||
func OptIntToInt64(i wbclient.OptInt) int64 {
|
||||
return int64(i.Value)
|
||||
}
|
||||
func OptStringToString(s wbclient.OptString) string {
|
||||
return s.Value
|
||||
}
|
||||
func WbDimensionsToProto(s wbclient.OptContentV2GetCardsListPostOKCardsItemDimensions) *proto.Product_Dimensions {
|
||||
result := proto.Product_Dimensions{}
|
||||
if !s.Set {
|
||||
return &result
|
||||
}
|
||||
value := s.Value
|
||||
result.Length = int64(value.Length.Value)
|
||||
result.Width = int64(value.Width.Value)
|
||||
result.WeightBrutto = float32(value.WeightBrutto.Value)
|
||||
result.IsValid = value.IsValid.Value
|
||||
return &result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user