Add Wildberries product fetching and rate limiting functionality
This commit is contained in:
		@@ -14,4 +14,5 @@ type Marketplace struct {
 | 
			
		||||
	Name            string
 | 
			
		||||
	AuthData        pgtype.Text
 | 
			
		||||
	WarehouseID     pgtype.Text
 | 
			
		||||
	AuthDataJson    []byte
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const getMarketplaceByID = `-- name: GetMarketplaceByID :one
 | 
			
		||||
SELECT id, base_marketplace, name, auth_data, warehouse_id FROM marketplaces
 | 
			
		||||
SELECT id, base_marketplace, name, auth_data, warehouse_id, auth_data_json FROM marketplaces
 | 
			
		||||
WHERE id = $1 LIMIT 1
 | 
			
		||||
`
 | 
			
		||||
 | 
			
		||||
@@ -23,6 +23,7 @@ func (q *Queries) GetMarketplaceByID(ctx context.Context, id int32) (Marketplace
 | 
			
		||||
		&i.Name,
 | 
			
		||||
		&i.AuthData,
 | 
			
		||||
		&i.WarehouseID,
 | 
			
		||||
		&i.AuthDataJson,
 | 
			
		||||
	)
 | 
			
		||||
	return i, err
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,14 @@
 | 
			
		||||
create table marketplaces
 | 
			
		||||
(
 | 
			
		||||
    id                           serial
 | 
			
		||||
    id               serial
 | 
			
		||||
        primary key,
 | 
			
		||||
    base_marketplace             integer                                        not null,
 | 
			
		||||
    name                         varchar                                        not null,
 | 
			
		||||
    auth_data                    varchar,
 | 
			
		||||
    warehouse_id                 varchar
 | 
			
		||||
    base_marketplace integer not null,
 | 
			
		||||
    name             varchar not null,
 | 
			
		||||
    auth_data        varchar,
 | 
			
		||||
    warehouse_id     varchar,
 | 
			
		||||
    auth_data_json   jsonb generated always as (
 | 
			
		||||
        CASE
 | 
			
		||||
            WHEN ((auth_data)::text IS JSON) THEN (auth_data)::jsonb
 | 
			
		||||
            ELSE NULL::jsonb
 | 
			
		||||
            END) stored
 | 
			
		||||
);
 | 
			
		||||
@@ -5,4 +5,5 @@ type Marketplace struct {
 | 
			
		||||
	BaseMarketplace int    `json:"base_marketplace"`
 | 
			
		||||
	AuthData        string `json:"auth_data"`
 | 
			
		||||
	WarehouseID     string `json:"warehouse_id"`
 | 
			
		||||
	AuthDataJson    []byte `json:"auth_data_json,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,5 +24,6 @@ func (r *dbRepository) GetMarketplaceByID(ctx context.Context, id int) (*Marketp
 | 
			
		||||
		BaseMarketplace: int(marketplace.BaseMarketplace),
 | 
			
		||||
		AuthData:        marketplace.AuthData.String,
 | 
			
		||||
		WarehouseID:     marketplace.WarehouseID.String,
 | 
			
		||||
		AuthDataJson:    marketplace.AuthDataJson,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user