chore: add bruno endpoints

This commit is contained in:
2026-04-03 09:22:58 +02:00
parent c31964c41b
commit d655e22173
21 changed files with 179 additions and 45 deletions

View File

@@ -1,11 +1,14 @@
package productsRepo
import (
"encoding/json"
"fmt"
"git.ma-al.com/goc_daniel/b2b/app/db"
)
type UIProductsRepo interface {
GetJSON(p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*string, error)
GetJSON(p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*json.RawMessage, error)
}
type ProductsRepo struct{}
@@ -14,12 +17,23 @@ func New() UIProductsRepo {
return &ProductsRepo{}
}
func (repo *ProductsRepo) GetJSON(p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*string, error) {
var product string
func (repo *ProductsRepo) GetJSON(p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*json.RawMessage, error) {
var productStr string // ← Scan as string first
err := db.DB.Raw(`CALL get_full_product(?,?,?,?,?,?)`, p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity).
Scan(&product).
err := db.DB.Raw(`CALL get_full_product(?,?,?,?,?,?)`,
p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity).
Scan(&productStr).
Error
return &product, err
if err != nil {
return nil, err
}
// Optional: validate it's valid JSON
if !json.Valid([]byte(productStr)) {
return nil, fmt.Errorf("invalid json returned from stored procedure")
}
raw := json.RawMessage(productStr)
return &raw, nil
}