Add gRPC server implementation and database integration for marketplace and products
This commit is contained in:
29
internal/marketplace/repository_db.go
Normal file
29
internal/marketplace/repository_db.go
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user