30 lines
689 B
Go
30 lines
689 B
Go
package marketplace
|
|
|
|
import (
|
|
"context"
|
|
"github.com/jackc/pgx/v5"
|
|
"sipro-mps/internal/marketplace/db"
|
|
)
|
|
|
|
type dbRepository struct {
|
|
conn *pgx.Conn
|
|
}
|
|
|
|
func NewDBRepository(conn *pgx.Conn) Repository {
|
|
return &dbRepository{conn: conn}
|
|
}
|
|
|
|
func (r *dbRepository) GetMarketplaceByID(ctx context.Context, id int) (*Marketplace, error) {
|
|
queries := db.New(r.conn)
|
|
marketplace, err := queries.GetMarketplaceByID(ctx, int32(id))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Marketplace{
|
|
ID: int(marketplace.ID),
|
|
BaseMarketplace: int(marketplace.BaseMarketplace),
|
|
AuthData: marketplace.AuthData.String,
|
|
WarehouseID: marketplace.WarehouseID.String,
|
|
}, nil
|
|
}
|