feat: ozon products recreator, small refactor
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,11 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
ProductsService_GetListOfProducts_FullMethodName = "/ozon.products.ProductsService/GetListOfProducts"
|
||||
ProductsService_GetProductPrice_FullMethodName = "/ozon.products.ProductsService/GetProductPrice"
|
||||
ProductsService_GetListOfProducts_FullMethodName = "/ozon.products.ProductsService/GetListOfProducts"
|
||||
ProductsService_GetProductPrice_FullMethodName = "/ozon.products.ProductsService/GetProductPrice"
|
||||
ProductsService_GetProductAttributes_FullMethodName = "/ozon.products.ProductsService/GetProductAttributes"
|
||||
ProductsService_DeleteProducts_FullMethodName = "/ozon.products.ProductsService/DeleteProducts"
|
||||
ProductsService_CreateOrUpdateProducts_FullMethodName = "/ozon.products.ProductsService/CreateOrUpdateProducts"
|
||||
)
|
||||
|
||||
// ProductsServiceClient is the client API for ProductsService service.
|
||||
@@ -30,6 +33,9 @@ type ProductsServiceClient interface {
|
||||
// Retrieves a list of products based on the provided request.
|
||||
GetListOfProducts(ctx context.Context, in *GetListOfProductsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GetListOfProductsResponse], error)
|
||||
GetProductPrice(ctx context.Context, in *GetProductPriceRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GetProductPriceResponse], error)
|
||||
GetProductAttributes(ctx context.Context, in *GetProductAttributesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GetProductAttributesResponse], error)
|
||||
DeleteProducts(ctx context.Context, in *DeleteProductsRequest, opts ...grpc.CallOption) (*DeleteProductsResponse, error)
|
||||
CreateOrUpdateProducts(ctx context.Context, in *CreateOrUpdateProductsRequest, opts ...grpc.CallOption) (*CreateOrUpdateProductsResponse, error)
|
||||
}
|
||||
|
||||
type productsServiceClient struct {
|
||||
@@ -78,6 +84,45 @@ func (c *productsServiceClient) GetProductPrice(ctx context.Context, in *GetProd
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type ProductsService_GetProductPriceClient = grpc.ServerStreamingClient[GetProductPriceResponse]
|
||||
|
||||
func (c *productsServiceClient) GetProductAttributes(ctx context.Context, in *GetProductAttributesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[GetProductAttributesResponse], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &ProductsService_ServiceDesc.Streams[2], ProductsService_GetProductAttributes_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[GetProductAttributesRequest, GetProductAttributesResponse]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type ProductsService_GetProductAttributesClient = grpc.ServerStreamingClient[GetProductAttributesResponse]
|
||||
|
||||
func (c *productsServiceClient) DeleteProducts(ctx context.Context, in *DeleteProductsRequest, opts ...grpc.CallOption) (*DeleteProductsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeleteProductsResponse)
|
||||
err := c.cc.Invoke(ctx, ProductsService_DeleteProducts_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *productsServiceClient) CreateOrUpdateProducts(ctx context.Context, in *CreateOrUpdateProductsRequest, opts ...grpc.CallOption) (*CreateOrUpdateProductsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CreateOrUpdateProductsResponse)
|
||||
err := c.cc.Invoke(ctx, ProductsService_CreateOrUpdateProducts_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ProductsServiceServer is the server API for ProductsService service.
|
||||
// All implementations must embed UnimplementedProductsServiceServer
|
||||
// for forward compatibility.
|
||||
@@ -85,6 +130,9 @@ type ProductsServiceServer interface {
|
||||
// Retrieves a list of products based on the provided request.
|
||||
GetListOfProducts(*GetListOfProductsRequest, grpc.ServerStreamingServer[GetListOfProductsResponse]) error
|
||||
GetProductPrice(*GetProductPriceRequest, grpc.ServerStreamingServer[GetProductPriceResponse]) error
|
||||
GetProductAttributes(*GetProductAttributesRequest, grpc.ServerStreamingServer[GetProductAttributesResponse]) error
|
||||
DeleteProducts(context.Context, *DeleteProductsRequest) (*DeleteProductsResponse, error)
|
||||
CreateOrUpdateProducts(context.Context, *CreateOrUpdateProductsRequest) (*CreateOrUpdateProductsResponse, error)
|
||||
mustEmbedUnimplementedProductsServiceServer()
|
||||
}
|
||||
|
||||
@@ -101,6 +149,15 @@ func (UnimplementedProductsServiceServer) GetListOfProducts(*GetListOfProductsRe
|
||||
func (UnimplementedProductsServiceServer) GetProductPrice(*GetProductPriceRequest, grpc.ServerStreamingServer[GetProductPriceResponse]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method GetProductPrice not implemented")
|
||||
}
|
||||
func (UnimplementedProductsServiceServer) GetProductAttributes(*GetProductAttributesRequest, grpc.ServerStreamingServer[GetProductAttributesResponse]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method GetProductAttributes not implemented")
|
||||
}
|
||||
func (UnimplementedProductsServiceServer) DeleteProducts(context.Context, *DeleteProductsRequest) (*DeleteProductsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteProducts not implemented")
|
||||
}
|
||||
func (UnimplementedProductsServiceServer) CreateOrUpdateProducts(context.Context, *CreateOrUpdateProductsRequest) (*CreateOrUpdateProductsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateOrUpdateProducts not implemented")
|
||||
}
|
||||
func (UnimplementedProductsServiceServer) mustEmbedUnimplementedProductsServiceServer() {}
|
||||
func (UnimplementedProductsServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -144,13 +201,69 @@ func _ProductsService_GetProductPrice_Handler(srv interface{}, stream grpc.Serve
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type ProductsService_GetProductPriceServer = grpc.ServerStreamingServer[GetProductPriceResponse]
|
||||
|
||||
func _ProductsService_GetProductAttributes_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(GetProductAttributesRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(ProductsServiceServer).GetProductAttributes(m, &grpc.GenericServerStream[GetProductAttributesRequest, GetProductAttributesResponse]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type ProductsService_GetProductAttributesServer = grpc.ServerStreamingServer[GetProductAttributesResponse]
|
||||
|
||||
func _ProductsService_DeleteProducts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteProductsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ProductsServiceServer).DeleteProducts(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ProductsService_DeleteProducts_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ProductsServiceServer).DeleteProducts(ctx, req.(*DeleteProductsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ProductsService_CreateOrUpdateProducts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateOrUpdateProductsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ProductsServiceServer).CreateOrUpdateProducts(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ProductsService_CreateOrUpdateProducts_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ProductsServiceServer).CreateOrUpdateProducts(ctx, req.(*CreateOrUpdateProductsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// ProductsService_ServiceDesc is the grpc.ServiceDesc for ProductsService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ProductsService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "ozon.products.ProductsService",
|
||||
HandlerType: (*ProductsServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "DeleteProducts",
|
||||
Handler: _ProductsService_DeleteProducts_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateOrUpdateProducts",
|
||||
Handler: _ProductsService_CreateOrUpdateProducts_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "GetListOfProducts",
|
||||
@@ -162,6 +275,11 @@ var ProductsService_ServiceDesc = grpc.ServiceDesc{
|
||||
Handler: _ProductsService_GetProductPrice_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "GetProductAttributes",
|
||||
Handler: _ProductsService_GetProductAttributes_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "ozon/products.proto",
|
||||
}
|
||||
|
||||
Submodule api/proto/v1 updated: 84924dc33f...7fe978865b
46
go.mod
46
go.mod
@@ -3,24 +3,24 @@ module sipro-mps
|
||||
go 1.24
|
||||
|
||||
require (
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250526003754-c6c303092505
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723023800-89aeba12d443
|
||||
github.com/go-faster/errors v0.7.1
|
||||
github.com/go-faster/jx v1.1.0
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
github.com/golang-jwt/jwt/v5 v5.2.3
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/hibiken/asynq v0.25.1
|
||||
github.com/jackc/pgx/v5 v5.7.5
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/ogen-go/ogen v1.14.0
|
||||
github.com/redis/rueidis v1.0.60
|
||||
github.com/samber/lo v1.50.0
|
||||
github.com/redis/rueidis v1.0.63
|
||||
github.com/samber/lo v1.51.0
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
go.opentelemetry.io/otel v1.36.0
|
||||
go.opentelemetry.io/otel/metric v1.36.0
|
||||
go.opentelemetry.io/otel/trace v1.36.0
|
||||
google.golang.org/grpc v1.72.2
|
||||
google.golang.org/protobuf v1.36.5
|
||||
go.opentelemetry.io/otel v1.37.0
|
||||
go.opentelemetry.io/otel/metric v1.37.0
|
||||
go.opentelemetry.io/otel/trace v1.37.0
|
||||
google.golang.org/grpc v1.74.2
|
||||
google.golang.org/protobuf v1.36.6
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -31,32 +31,32 @@ require (
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/ghodss/yaml v1.0.0 // indirect
|
||||
github.com/go-faster/yaml v0.4.6 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jmattheis/goverter v1.9.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/redis/go-redis/v9 v9.7.0 // indirect
|
||||
github.com/redis/go-redis/v9 v9.11.0 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||
github.com/segmentio/asm v1.2.0 // indirect
|
||||
github.com/spf13/cast v1.7.0 // indirect
|
||||
github.com/spf13/cast v1.9.2 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/crypto v0.38.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect
|
||||
golang.org/x/mod v0.24.0 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
golang.org/x/time v0.8.0 // indirect
|
||||
golang.org/x/tools v0.33.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
|
||||
golang.org/x/crypto v0.40.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 // indirect
|
||||
golang.org/x/mod v0.26.0 // indirect
|
||||
golang.org/x/net v0.42.0 // indirect
|
||||
golang.org/x/sync v0.16.0 // indirect
|
||||
golang.org/x/sys v0.34.0 // indirect
|
||||
golang.org/x/text v0.27.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
golang.org/x/tools v0.35.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250721164621-a45f3dfb1074 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
54
go.sum
54
go.sum
@@ -1,5 +1,11 @@
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250526003754-c6c303092505 h1:5mviYMLXLIvsFEXLR0IlGuqMNzkB8X/yrmxZHYk0n84=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250526003754-c6c303092505/go.mod h1:1uPm278HN7mDkP507KHsLpnW+R9vWGEzp9BSMycjVbQ=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723012308-3e6c8fbc0564 h1:HcuTzIudt97E6OnydVqqp7pOCMACOhWrtFmIVhtM7xU=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723012308-3e6c8fbc0564/go.mod h1:1uPm278HN7mDkP507KHsLpnW+R9vWGEzp9BSMycjVbQ=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723013247-1e2c591a70e9 h1:iYj23C0/ju0awoWA+MqunFa+YIYQkOSK9jUF8Eqpbks=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723013247-1e2c591a70e9/go.mod h1:1uPm278HN7mDkP507KHsLpnW+R9vWGEzp9BSMycjVbQ=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723023800-89aeba12d443 h1:EOwa2tU1GloC079TdXZq/+fRrXRvkdPnH8vWxgcxxYg=
|
||||
git.denco.store/fakz9/ozon-api-client v1.18.1-0.20250723023800-89aeba12d443/go.mod h1:1uPm278HN7mDkP507KHsLpnW+R9vWGEzp9BSMycjVbQ=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
@@ -30,10 +36,14 @@ github.com/go-faster/yaml v0.4.6/go.mod h1:390dRIvV4zbnO7qC9FGo6YYutc+wyyUSHBgbX
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.3 h1:kkGXqQOBSDDWRhWNXTFpqGSCMyh/PLnqUvMGJPDJDs0=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.3/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
@@ -62,6 +72,8 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
@@ -73,18 +85,26 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
|
||||
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
|
||||
github.com/redis/go-redis/v9 v9.11.0 h1:E3S08Gl/nJNn5vkxd2i78wZxWAPNZgUNTp8WIJUAiIs=
|
||||
github.com/redis/go-redis/v9 v9.11.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||
github.com/redis/rueidis v1.0.60 h1:MGZX8uNdw7iyWz22JhjA/9iXzddfCUE/EMK4VxKoKpA=
|
||||
github.com/redis/rueidis v1.0.60/go.mod h1:Lkhr2QTgcoYBhxARU7kJRO8SyVlgUuEkcJO1Y8MCluA=
|
||||
github.com/redis/rueidis v1.0.63 h1:zSt5focn0YgrgBAE5NcnAibyKf3ZKyv+eCQHk62jEFk=
|
||||
github.com/redis/rueidis v1.0.63/go.mod h1:Lkhr2QTgcoYBhxARU7kJRO8SyVlgUuEkcJO1Y8MCluA=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/samber/lo v1.50.0 h1:XrG0xOeHs+4FQ8gJR97zDz5uOFMW7OwFWiFVzqopKgY=
|
||||
github.com/samber/lo v1.50.0/go.mod h1:RjZyNk6WSnUFRKK6EyOhsRJMqft3G+pg7dCWHQCWvsc=
|
||||
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
||||
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
|
||||
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@@ -101,14 +121,20 @@ go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJyS
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
|
||||
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
|
||||
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
|
||||
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
|
||||
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
|
||||
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
|
||||
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
|
||||
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
|
||||
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
|
||||
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
|
||||
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
|
||||
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
|
||||
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
|
||||
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
@@ -117,30 +143,50 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
||||
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY=
|
||||
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
|
||||
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 h1:R9PFI6EUdfVKgwKjZef7QIwGcBKu86OEFpJ9nUEP2l4=
|
||||
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792/go.mod h1:A+z0yzpGtvnG90cToK5n2tu8UJVP2XUATh+r+sfOOOc=
|
||||
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
|
||||
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
||||
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
||||
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
||||
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
|
||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
|
||||
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
|
||||
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
|
||||
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
|
||||
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250721164621-a45f3dfb1074 h1:qJW29YvkiJmXOYMu5Tf8lyrTp3dOS+K4z6IixtLaCf8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250721164621-a45f3dfb1074/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8=
|
||||
google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
|
||||
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
|
||||
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package products
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/samber/lo"
|
||||
"google.golang.org/grpc"
|
||||
@@ -59,3 +60,53 @@ func (g *AdapterGRPC) GetListOfProducts(req *pb.GetListOfProductsRequest, stream
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g *AdapterGRPC) GetProductAttributes(req *pb.GetProductAttributesRequest, stream pb.ProductsService_GetProductAttributesServer) error {
|
||||
ctx := stream.Context()
|
||||
|
||||
resultChan := make(chan []pb.ProductAttributes, 10)
|
||||
errChan := make(chan error)
|
||||
productIds := lo.Map(req.ProductId, func(item int64, index int) int {
|
||||
return int(item)
|
||||
})
|
||||
go g.repo.StreamProductAttributesCache(ctx, int(req.MarketplaceId), productIds, resultChan, errChan)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case attrs, ok := <-resultChan:
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
items := lo.Map(attrs, func(item pb.ProductAttributes, index int) *pb.ProductAttributes {
|
||||
return &item
|
||||
})
|
||||
resp := pb.GetProductAttributesResponse{Items: items}
|
||||
if err := stream.Send(&resp); err != nil {
|
||||
return err
|
||||
}
|
||||
case err, ok := <-errChan:
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g *AdapterGRPC) DeleteProducts(ctx context.Context, req *pb.DeleteProductsRequest) (*pb.DeleteProductsResponse, error) {
|
||||
responseItems, err := g.repo.DeleteProducts(ctx, int(req.MarketplaceId), req.Items)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.DeleteProductsResponse{
|
||||
MarketplaceId: req.MarketplaceId,
|
||||
Items: responseItems,
|
||||
},
|
||||
nil
|
||||
}
|
||||
|
||||
func (g *AdapterGRPC) CreateOrUpdateProducts(ctx context.Context, req *pb.CreateOrUpdateProductsRequest) (*pb.CreateOrUpdateProductsResponse, error) {
|
||||
return g.repo.CreateOrUpdateProducts(ctx, int(req.MarketplaceId), req.Items)
|
||||
}
|
||||
|
||||
@@ -7,3 +7,8 @@ import (
|
||||
|
||||
type OzonProduct = ozon.ProductDetails
|
||||
type PbProduct = pb.Product
|
||||
type PbProductAttributes = pb.ProductAttributes
|
||||
type PbDeleteProductRequestItem = pb.DeleteProductsRequest_Item
|
||||
type PbDeleteProductResponseItem = pb.DeleteProductsResponse_Item
|
||||
type PbCreateOrUpdateItem = pb.CreateOrUpdateProductsRequest_Item
|
||||
type PbCreateOrUpdateProductsResponse = pb.CreateOrUpdateProductsResponse
|
||||
|
||||
@@ -8,13 +8,21 @@ import (
|
||||
//go:generate go run github.com/jmattheis/goverter/cmd/goverter gen -global "ignoreUnexported yes" .
|
||||
|
||||
// goverter:converter
|
||||
// goverter:extend Int632ToInt64
|
||||
// goverter:extend Int32ToInt64 Int64ToInt32
|
||||
// goverter:matchIgnoreCase yes
|
||||
// goverter:useZeroValueOnPointerInconsistency yes
|
||||
type Converter interface {
|
||||
// goverter:ignore state sizeCache unknownFields
|
||||
|
||||
ToProto(details *internal.ProductDetails) *proto.Product
|
||||
AttributesToProto(attrs *internal.GetDescriptionOfProductsResult) *proto.ProductAttributes
|
||||
// goverter:ignore ComplexAttributes GeoNames
|
||||
ProtoToUpdateItem(update *proto.CreateOrUpdateProductsRequest_Item) *internal.CreateOrUpdateProductItem
|
||||
}
|
||||
|
||||
func Int632ToInt64(i int32) int64 {
|
||||
func Int32ToInt64(i int32) int64 {
|
||||
return int64(i)
|
||||
}
|
||||
func Int64ToInt32(i int64) int32 {
|
||||
return int32(i)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,92 @@ import (
|
||||
|
||||
type ConverterImpl struct{}
|
||||
|
||||
func (c *ConverterImpl) AttributesToProto(source *ozon.GetDescriptionOfProductsResult) *products.ProductAttributes {
|
||||
var pProductsProductAttributes *products.ProductAttributes
|
||||
if source != nil {
|
||||
var productsProductAttributes products.ProductAttributes
|
||||
productsProductAttributes.Id = (*source).Id
|
||||
productsProductAttributes.Barcode = (*source).Barcode
|
||||
productsProductAttributes.Name = (*source).Name
|
||||
productsProductAttributes.OfferId = (*source).OfferId
|
||||
productsProductAttributes.TypeId = (*source).TypeId
|
||||
productsProductAttributes.Height = mapping.Int32ToInt64((*source).Height)
|
||||
productsProductAttributes.Depth = mapping.Int32ToInt64((*source).Depth)
|
||||
productsProductAttributes.Width = mapping.Int32ToInt64((*source).Width)
|
||||
productsProductAttributes.DimensionUnit = (*source).DimensionUnit
|
||||
productsProductAttributes.Weight = mapping.Int32ToInt64((*source).Weight)
|
||||
productsProductAttributes.WeightUnit = (*source).WeightUnit
|
||||
productsProductAttributes.PrimaryImage = (*source).PrimaryImage
|
||||
productsProductAttributes.ModelInfo = c.pOzonModelInfoToPProductsProductAttributes_ModelInfo((*source).ModelInfo)
|
||||
if (*source).Images != nil {
|
||||
productsProductAttributes.Images = make([]string, len((*source).Images))
|
||||
for i := 0; i < len((*source).Images); i++ {
|
||||
productsProductAttributes.Images[i] = (*source).Images[i]
|
||||
}
|
||||
}
|
||||
if (*source).Attributes != nil {
|
||||
productsProductAttributes.Attributes = make([]*products.ProductAttributes_Attributes, len((*source).Attributes))
|
||||
for j := 0; j < len((*source).Attributes); j++ {
|
||||
productsProductAttributes.Attributes[j] = c.ozonGetDescriptionOfProductsAttributeToPProductsProductAttributes_Attributes((*source).Attributes[j])
|
||||
}
|
||||
}
|
||||
productsProductAttributes.ColorImage = (*source).ColorImage
|
||||
productsProductAttributes.DescriptionCategoryId = (*source).DescriptionCategoryId
|
||||
pProductsProductAttributes = &productsProductAttributes
|
||||
}
|
||||
return pProductsProductAttributes
|
||||
}
|
||||
func (c *ConverterImpl) ProtoToUpdateItem(source *products.CreateOrUpdateProductsRequest_Item) *ozon.CreateOrUpdateProductItem {
|
||||
var pOzonCreateOrUpdateProductItem *ozon.CreateOrUpdateProductItem
|
||||
if source != nil {
|
||||
var ozonCreateOrUpdateProductItem ozon.CreateOrUpdateProductItem
|
||||
if (*source).Attributes != nil {
|
||||
ozonCreateOrUpdateProductItem.Attributes = make([]ozon.CreateOrUpdateAttribute, len((*source).Attributes))
|
||||
for i := 0; i < len((*source).Attributes); i++ {
|
||||
ozonCreateOrUpdateProductItem.Attributes[i] = c.pProductsCreateOrUpdateProductsRequest_Item_AttributesToOzonCreateOrUpdateAttribute((*source).Attributes[i])
|
||||
}
|
||||
}
|
||||
ozonCreateOrUpdateProductItem.Barcode = (*source).Barcode
|
||||
ozonCreateOrUpdateProductItem.DescriptionCategoryId = (*source).DescriptionCategoryId
|
||||
ozonCreateOrUpdateProductItem.NewDescriptionCategoryId = (*source).NewDescriptionCategoryId
|
||||
ozonCreateOrUpdateProductItem.ColorImage = (*source).ColorImage
|
||||
ozonCreateOrUpdateProductItem.Depth = mapping.Int64ToInt32((*source).Depth)
|
||||
ozonCreateOrUpdateProductItem.DimensionUnit = (*source).DimensionUnit
|
||||
ozonCreateOrUpdateProductItem.Height = mapping.Int64ToInt32((*source).Height)
|
||||
if (*source).Images != nil {
|
||||
ozonCreateOrUpdateProductItem.Images = make([]string, len((*source).Images))
|
||||
for j := 0; j < len((*source).Images); j++ {
|
||||
ozonCreateOrUpdateProductItem.Images[j] = (*source).Images[j]
|
||||
}
|
||||
}
|
||||
ozonCreateOrUpdateProductItem.PrimaryImage = (*source).PrimaryImage
|
||||
if (*source).Images360 != nil {
|
||||
ozonCreateOrUpdateProductItem.Images360 = make([]string, len((*source).Images360))
|
||||
for k := 0; k < len((*source).Images360); k++ {
|
||||
ozonCreateOrUpdateProductItem.Images360[k] = (*source).Images360[k]
|
||||
}
|
||||
}
|
||||
ozonCreateOrUpdateProductItem.Name = (*source).Name
|
||||
ozonCreateOrUpdateProductItem.OfferId = (*source).OfferId
|
||||
ozonCreateOrUpdateProductItem.CurrencyCode = (*source).CurrencyCode
|
||||
ozonCreateOrUpdateProductItem.OldPrice = (*source).OldPrice
|
||||
if (*source).PdfList != nil {
|
||||
ozonCreateOrUpdateProductItem.PDFList = make([]ozon.CreateOrUpdateProductPDF, len((*source).PdfList))
|
||||
for l := 0; l < len((*source).PdfList); l++ {
|
||||
ozonCreateOrUpdateProductItem.PDFList[l] = c.pProductsCreateOrUpdateProductsRequest_Item_PdfListItemToOzonCreateOrUpdateProductPDF((*source).PdfList[l])
|
||||
}
|
||||
}
|
||||
ozonCreateOrUpdateProductItem.Price = (*source).Price
|
||||
ozonCreateOrUpdateProductItem.ServiceType = (*source).ServiceType
|
||||
ozonCreateOrUpdateProductItem.TypeId = (*source).TypeId
|
||||
ozonCreateOrUpdateProductItem.VAT = ozon.VAT((*source).Vat)
|
||||
ozonCreateOrUpdateProductItem.Weight = mapping.Int64ToInt32((*source).Weight)
|
||||
ozonCreateOrUpdateProductItem.WeightUnit = (*source).WeightUnit
|
||||
ozonCreateOrUpdateProductItem.Width = mapping.Int64ToInt32((*source).Width)
|
||||
pOzonCreateOrUpdateProductItem = &ozonCreateOrUpdateProductItem
|
||||
}
|
||||
return pOzonCreateOrUpdateProductItem
|
||||
}
|
||||
func (c *ConverterImpl) ToProto(source *ozon.ProductDetails) *products.Product {
|
||||
var pProductsProduct *products.Product
|
||||
if source != nil {
|
||||
@@ -25,14 +111,38 @@ func (c *ConverterImpl) ToProto(source *ozon.ProductDetails) *products.Product {
|
||||
}
|
||||
}
|
||||
productsProduct.Statuses = c.ozonProductDetailsStatusToPProductsProduct_Status((*source).Statuses)
|
||||
if (*source).Errors != nil {
|
||||
productsProduct.Errors = make([]*products.Product_Error, len((*source).Errors))
|
||||
for j := 0; j < len((*source).Errors); j++ {
|
||||
productsProduct.Errors[j] = c.ozonProductDetailsErrorToPProductsProduct_Error((*source).Errors[j])
|
||||
}
|
||||
}
|
||||
pProductsProduct = &productsProduct
|
||||
}
|
||||
return pProductsProduct
|
||||
}
|
||||
func (c *ConverterImpl) ozonGetDescriptionOfProductsAttributeToPProductsProductAttributes_Attributes(source ozon.GetDescriptionOfProductsAttribute) *products.ProductAttributes_Attributes {
|
||||
var productsProductAttributes_Attributes products.ProductAttributes_Attributes
|
||||
productsProductAttributes_Attributes.Id = source.Id
|
||||
productsProductAttributes_Attributes.ComplexId = source.ComplexId
|
||||
if source.Values != nil {
|
||||
productsProductAttributes_Attributes.Values = make([]*products.ProductAttributes_Values, len(source.Values))
|
||||
for i := 0; i < len(source.Values); i++ {
|
||||
productsProductAttributes_Attributes.Values[i] = c.ozonGetDescriptionOfProductsAttributeValueToPProductsProductAttributes_Values(source.Values[i])
|
||||
}
|
||||
}
|
||||
return &productsProductAttributes_Attributes
|
||||
}
|
||||
func (c *ConverterImpl) ozonGetDescriptionOfProductsAttributeValueToPProductsProductAttributes_Values(source ozon.GetDescriptionOfProductsAttributeValue) *products.ProductAttributes_Values {
|
||||
var productsProductAttributes_Values products.ProductAttributes_Values
|
||||
productsProductAttributes_Values.DictionaryValueId = source.DictionaryValueId
|
||||
productsProductAttributes_Values.Value = source.Value
|
||||
return &productsProductAttributes_Values
|
||||
}
|
||||
func (c *ConverterImpl) ozonProductDetailStockStockToPProductsProduct_Stock(source ozon.ProductDetailStockStock) *products.Product_Stock {
|
||||
var productsProduct_Stock products.Product_Stock
|
||||
productsProduct_Stock.Present = mapping.Int632ToInt64(source.Present)
|
||||
productsProduct_Stock.Reserved = mapping.Int632ToInt64(source.Reserved)
|
||||
productsProduct_Stock.Present = mapping.Int32ToInt64(source.Present)
|
||||
productsProduct_Stock.Reserved = mapping.Int32ToInt64(source.Reserved)
|
||||
productsProduct_Stock.SKU = source.SKU
|
||||
productsProduct_Stock.Source = source.Source
|
||||
return &productsProduct_Stock
|
||||
@@ -48,8 +158,60 @@ func (c *ConverterImpl) ozonProductDetailStockToPProductsProduct_Stocks(source o
|
||||
productsProduct_Stocks.HasStock = source.HasStock
|
||||
return &productsProduct_Stocks
|
||||
}
|
||||
func (c *ConverterImpl) ozonProductDetailsErrorToPProductsProduct_Error(source ozon.ProductDetailsError) *products.Product_Error {
|
||||
var productsProduct_Error products.Product_Error
|
||||
productsProduct_Error.Code = source.Code
|
||||
return &productsProduct_Error
|
||||
}
|
||||
func (c *ConverterImpl) ozonProductDetailsStatusToPProductsProduct_Status(source ozon.ProductDetailsStatus) *products.Product_Status {
|
||||
var productsProduct_Status products.Product_Status
|
||||
productsProduct_Status.StatusName = source.StatusName
|
||||
return &productsProduct_Status
|
||||
}
|
||||
func (c *ConverterImpl) pOzonModelInfoToPProductsProductAttributes_ModelInfo(source *ozon.ModelInfo) *products.ProductAttributes_ModelInfo {
|
||||
var pProductsProductAttributes_ModelInfo *products.ProductAttributes_ModelInfo
|
||||
if source != nil {
|
||||
var productsProductAttributes_ModelInfo products.ProductAttributes_ModelInfo
|
||||
productsProductAttributes_ModelInfo.ModelId = (*source).ModelId
|
||||
productsProductAttributes_ModelInfo.Count = (*source).Count
|
||||
pProductsProductAttributes_ModelInfo = &productsProductAttributes_ModelInfo
|
||||
}
|
||||
return pProductsProductAttributes_ModelInfo
|
||||
}
|
||||
func (c *ConverterImpl) pProductsCreateOrUpdateProductsRequest_Item_AttributesToOzonCreateOrUpdateAttribute(source *products.CreateOrUpdateProductsRequest_Item_Attributes) ozon.CreateOrUpdateAttribute {
|
||||
var ozonCreateOrUpdateAttribute ozon.CreateOrUpdateAttribute
|
||||
if source != nil {
|
||||
var ozonCreateOrUpdateAttribute2 ozon.CreateOrUpdateAttribute
|
||||
ozonCreateOrUpdateAttribute2.ComplexId = (*source).ComplexId
|
||||
ozonCreateOrUpdateAttribute2.Id = (*source).Id
|
||||
if (*source).Values != nil {
|
||||
ozonCreateOrUpdateAttribute2.Values = make([]ozon.CreateOrUpdateAttributeValue, len((*source).Values))
|
||||
for i := 0; i < len((*source).Values); i++ {
|
||||
ozonCreateOrUpdateAttribute2.Values[i] = c.pProductsCreateOrUpdateProductsRequest_Item_ValuesToOzonCreateOrUpdateAttributeValue((*source).Values[i])
|
||||
}
|
||||
}
|
||||
ozonCreateOrUpdateAttribute = ozonCreateOrUpdateAttribute2
|
||||
}
|
||||
return ozonCreateOrUpdateAttribute
|
||||
}
|
||||
func (c *ConverterImpl) pProductsCreateOrUpdateProductsRequest_Item_PdfListItemToOzonCreateOrUpdateProductPDF(source *products.CreateOrUpdateProductsRequest_Item_PdfListItem) ozon.CreateOrUpdateProductPDF {
|
||||
var ozonCreateOrUpdateProductPDF ozon.CreateOrUpdateProductPDF
|
||||
if source != nil {
|
||||
var ozonCreateOrUpdateProductPDF2 ozon.CreateOrUpdateProductPDF
|
||||
ozonCreateOrUpdateProductPDF2.Index = (*source).Index
|
||||
ozonCreateOrUpdateProductPDF2.Name = (*source).Name
|
||||
ozonCreateOrUpdateProductPDF2.SrcUrl = (*source).SrcUrl
|
||||
ozonCreateOrUpdateProductPDF = ozonCreateOrUpdateProductPDF2
|
||||
}
|
||||
return ozonCreateOrUpdateProductPDF
|
||||
}
|
||||
func (c *ConverterImpl) pProductsCreateOrUpdateProductsRequest_Item_ValuesToOzonCreateOrUpdateAttributeValue(source *products.CreateOrUpdateProductsRequest_Item_Values) ozon.CreateOrUpdateAttributeValue {
|
||||
var ozonCreateOrUpdateAttributeValue ozon.CreateOrUpdateAttributeValue
|
||||
if source != nil {
|
||||
var ozonCreateOrUpdateAttributeValue2 ozon.CreateOrUpdateAttributeValue
|
||||
ozonCreateOrUpdateAttributeValue2.DictionaryValueId = (*source).DictionaryValueId
|
||||
ozonCreateOrUpdateAttributeValue2.Value = (*source).Value
|
||||
ozonCreateOrUpdateAttributeValue = ozonCreateOrUpdateAttributeValue2
|
||||
}
|
||||
return ozonCreateOrUpdateAttributeValue
|
||||
}
|
||||
|
||||
@@ -6,4 +6,7 @@ type Repository interface {
|
||||
GetAllProducts(ctx context.Context, marketplaceId int) ([]OzonProduct, error)
|
||||
StreamAllProducts(ctx context.Context, marketplaceId int, resultChan chan<- []OzonProduct, errChan chan<- error)
|
||||
StreamAllProductsCache(ctx context.Context, marketplaceId int, resultChan chan<- []PbProduct, errChan chan<- error)
|
||||
StreamProductAttributesCache(ctx context.Context, marketplaceId int, productIds []int, resultChan chan<- []PbProductAttributes, errChan chan<- error)
|
||||
DeleteProducts(ctx context.Context, marketplaceId int, items []*PbDeleteProductRequestItem) ([]*PbDeleteProductResponseItem, error)
|
||||
CreateOrUpdateProducts(ctx context.Context, marketplaceId int, items []*PbCreateOrUpdateItem) (*PbCreateOrUpdateProductsResponse, error)
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ import (
|
||||
"fmt"
|
||||
api "git.denco.store/fakz9/ozon-api-client/ozon"
|
||||
"github.com/samber/lo"
|
||||
pb "sipro-mps/api/generated/v1/ozon/products"
|
||||
"sipro-mps/internal/marketplace"
|
||||
"sipro-mps/internal/ozon"
|
||||
"sipro-mps/internal/ozon/products/mapping/generated"
|
||||
"sipro-mps/internal/redis"
|
||||
"sipro-mps/internal/tasks/client"
|
||||
"sipro-mps/internal/tasks/types"
|
||||
"strconv"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -202,3 +204,125 @@ func (a *apiRepository) StreamAllProductsCache(ctx context.Context, marketplaceI
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *apiRepository) StreamProductAttributesCache(ctx context.Context, marketplaceId int, productIds []int, resultChan chan<- []PbProductAttributes, errChan chan<- error) {
|
||||
defer close(resultChan)
|
||||
defer close(errChan)
|
||||
|
||||
mp, err := a.marketplaceRepository.GetMarketplaceByID(ctx, marketplaceId)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
ozonClient, err := ozon.GetClientFromMarketplace(mp)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
converter := generated.ConverterImpl{}
|
||||
for _, chunk := range lo.Chunk(productIds, 1000) {
|
||||
chunkStrings := lo.Map(chunk, func(item int, index int) string {
|
||||
return strconv.Itoa(item)
|
||||
})
|
||||
request := api.GetDescriptionOfProductsParams{
|
||||
LastId: "",
|
||||
Limit: 1000,
|
||||
SortBy: "id",
|
||||
SortDirection: "asc",
|
||||
Filter: api.GetDescriptionOfProductsFilter{ProductId: chunkStrings},
|
||||
}
|
||||
response, err := ozonClient.Products().GetDescriptionOfProducts(ctx, &request)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
resultChan <- lo.Map(response.Result, func(item api.GetDescriptionOfProductsResult, index int) pb.ProductAttributes {
|
||||
return *converter.AttributesToProto(&item)
|
||||
})
|
||||
|
||||
}
|
||||
//ozonClient.Products().GetDescriptionOfProducts()
|
||||
}
|
||||
|
||||
func (a *apiRepository) DeleteProducts(ctx context.Context, marketplaceId int, items []*PbDeleteProductRequestItem) ([]*PbDeleteProductResponseItem, error) {
|
||||
mp, err := a.marketplaceRepository.GetMarketplaceByID(ctx, marketplaceId)
|
||||
|
||||
if err != nil {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
ozonClient, err := ozon.GetClientFromMarketplace(mp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Step 1: map the items into a slice
|
||||
mapped := lo.Map(items, func(item *PbDeleteProductRequestItem, _ int) *PbDeleteProductResponseItem {
|
||||
return &PbDeleteProductResponseItem{
|
||||
ProductId: item.ProductId,
|
||||
OfferId: item.OfferId,
|
||||
IsDeleted: false,
|
||||
}
|
||||
})
|
||||
|
||||
// Step 2: create the map keyed by OfferId
|
||||
result := lo.KeyBy(mapped, func(item *PbDeleteProductResponseItem) string {
|
||||
return item.OfferId
|
||||
})
|
||||
|
||||
for _, chunk := range lo.Chunk(items, 100) {
|
||||
productIds := lo.Map(chunk, func(item *PbDeleteProductRequestItem, index int) int64 {
|
||||
return item.ProductId
|
||||
})
|
||||
request := api.ArchiveProductParams{ProductId: productIds}
|
||||
_, err := ozonClient.Products().ArchiveProduct(ctx, &request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, chunk := range lo.Chunk(items, 500) {
|
||||
products := lo.Map(chunk, func(item *PbDeleteProductRequestItem, index int) api.RemoveProductWithoutSKUProduct {
|
||||
return api.RemoveProductWithoutSKUProduct{OfferId: item.OfferId}
|
||||
})
|
||||
request := api.RemoveProductWithoutSKUParams{Products: products}
|
||||
response, err := ozonClient.Products().RemoveProductWithoutSKU(ctx, &request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, status := range response.Status {
|
||||
if item, ok := result[status.OfferId]; ok {
|
||||
item.IsDeleted = status.IsDeleted
|
||||
}
|
||||
}
|
||||
}
|
||||
return lo.Values(result), nil
|
||||
}
|
||||
|
||||
func (a *apiRepository) CreateOrUpdateProducts(ctx context.Context, marketplaceId int, items []*PbCreateOrUpdateItem) (*PbCreateOrUpdateProductsResponse, error) {
|
||||
mp, err := a.marketplaceRepository.GetMarketplaceByID(ctx, marketplaceId)
|
||||
|
||||
if err != nil {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
ozonClient, err := ozon.GetClientFromMarketplace(mp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
converter := generated.ConverterImpl{}
|
||||
pageSize := 100
|
||||
result := make([]int64, (len(items)+pageSize-1)/pageSize)
|
||||
for idx, chunk := range lo.Chunk(items, pageSize) {
|
||||
mappedItems := lo.Map(chunk, func(item *PbCreateOrUpdateItem, index int) api.CreateOrUpdateProductItem {
|
||||
return *converter.ProtoToUpdateItem(item)
|
||||
})
|
||||
request := api.CreateOrUpdateProductParams{Items: mappedItems}
|
||||
response, err := ozonClient.Products().CreateOrUpdateProduct(ctx, &request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[idx] = response.Result.TaskId
|
||||
}
|
||||
|
||||
return &pb.CreateOrUpdateProductsResponse{TaskId: result}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user