chore: add bruno endpoints
This commit is contained in:
@@ -32,7 +32,6 @@ func CurrencyHandlerRoutes(r fiber.Router) fiber.Router {
|
|||||||
|
|
||||||
r.Post("/currency-rate", handler.PostCurrencyRate)
|
r.Post("/currency-rate", handler.PostCurrencyRate)
|
||||||
r.Get("/currency-rate/:id", handler.GetCurrencyRate)
|
r.Get("/currency-rate/:id", handler.GetCurrencyRate)
|
||||||
// r.Get("/currencies", handler.GetCurrencyRates)
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,33 +64,5 @@ func (h *CurrencyHandler) GetCurrencyRate(c fiber.Ctx) error {
|
|||||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
return c.Status(responseErrors.GetErrorStatus(err)).JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// err = h.CurrencyService.GetCurrencyRate(userID, uint(productID), uint(productShopID), uint(productLangID), updates)
|
|
||||||
// if err != nil {
|
|
||||||
// return c.Status(responseErrors.GetErrorStatus(err)).
|
|
||||||
// JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
|
||||||
// }
|
|
||||||
|
|
||||||
return c.JSON(response.Make(currency, 0, i18n.T_(c, response.Message_OK)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *CurrencyHandler) GetCurrencyRates(c fiber.Ctx) error {
|
|
||||||
idStr := c.Params("id")
|
|
||||||
id, err := strconv.Atoi(idStr)
|
|
||||||
if err != nil {
|
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
currency, err := h.CurrencyService.GetCurrency(uint(id))
|
|
||||||
if err != nil {
|
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// err = h.CurrencyService.GetCurrencyRate(userID, uint(productID), uint(productShopID), uint(productLangID), updates)
|
|
||||||
// if err != nil {
|
|
||||||
// return c.Status(responseErrors.GetErrorStatus(err)).
|
|
||||||
// JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
|
||||||
// }
|
|
||||||
|
|
||||||
return c.JSON(response.Make(currency, 0, i18n.T_(c, response.Message_OK)))
|
return c.JSON(response.Make(currency, 0, i18n.T_(c, response.Message_OK)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ func NewProductsHandler() *ProductsHandler {
|
|||||||
func ProductsHandlerRoutes(r fiber.Router) fiber.Router {
|
func ProductsHandlerRoutes(r fiber.Router) fiber.Router {
|
||||||
handler := NewProductsHandler()
|
handler := NewProductsHandler()
|
||||||
|
|
||||||
//TODO: WIP doesn't work yet
|
|
||||||
r.Get("/:id/:country_id/:quantity", handler.GetProductJson)
|
r.Get("/:id/:country_id/:quantity", handler.GetProductJson)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package productsRepo
|
package productsRepo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.ma-al.com/goc_daniel/b2b/app/db"
|
"git.ma-al.com/goc_daniel/b2b/app/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UIProductsRepo interface {
|
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{}
|
type ProductsRepo struct{}
|
||||||
@@ -14,12 +17,23 @@ func New() UIProductsRepo {
|
|||||||
return &ProductsRepo{}
|
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) {
|
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 product string
|
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).
|
err := db.DB.Raw(`CALL get_full_product(?,?,?,?,?,?)`,
|
||||||
Scan(&product).
|
p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity).
|
||||||
|
Scan(&productStr).
|
||||||
Error
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package productService
|
package productService
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"git.ma-al.com/goc_daniel/b2b/app/repos/productsRepo"
|
"git.ma-al.com/goc_daniel/b2b/app/repos/productsRepo"
|
||||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||||
)
|
)
|
||||||
@@ -15,7 +17,7 @@ func New() *ProductService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ProductService) GetJSON(p_id_product, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*string, error) {
|
func (s *ProductService) GetJSON(p_id_product, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*json.RawMessage, error) {
|
||||||
products, err := s.productsRepo.GetJSON(p_id_product, constdata.SHOP_ID, p_id_lang, p_id_customer, b2b_id_country, p_quantity)
|
products, err := s.productsRepo.GetJSON(p_id_product, constdata.SHOP_ID, p_id_lang, p_id_customer, b2b_id_country, p_quantity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return products, err
|
return products, err
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Change Locales
|
name: Change Locales
|
||||||
type: http
|
type: http
|
||||||
seq: 4
|
seq: 3
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Create Search Index
|
name: Create Search Index
|
||||||
type: http
|
type: http
|
||||||
seq: 2
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Delete Index - MeiliSearch
|
name: Delete Index - MeiliSearch
|
||||||
type: http
|
type: http
|
||||||
seq: 7
|
seq: 5
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: DELETE
|
method: DELETE
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Search Index Settings
|
name: Search Index Settings
|
||||||
type: http
|
type: http
|
||||||
seq: 5
|
seq: 4
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Search Items
|
name: Search Items
|
||||||
type: http
|
type: http
|
||||||
seq: 3
|
seq: 2
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
|
|||||||
29
bruno/api_v1/auth/Login.yml
Normal file
29
bruno/api_v1/auth/Login.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
info:
|
||||||
|
name: Login
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: POST
|
||||||
|
url: "{{bas_url}}/public/auth/login"
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
data: |-
|
||||||
|
{
|
||||||
|
"email":"{{email}}",
|
||||||
|
"password":"{{password}}"
|
||||||
|
}
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
runtime:
|
||||||
|
variables:
|
||||||
|
- name: email
|
||||||
|
value: admin@ma-al.com
|
||||||
|
- name: password
|
||||||
|
value: Maal12345678
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
7
bruno/api_v1/auth/folder.yml
Normal file
7
bruno/api_v1/auth/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: auth
|
||||||
|
type: folder
|
||||||
|
seq: 6
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
15
bruno/api_v1/currency/currency-rate.yml
Normal file
15
bruno/api_v1/currency/currency-rate.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
info:
|
||||||
|
name: currency-rate
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: POST
|
||||||
|
url: "{{bas_url}}/restricted/currency-rate"
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
20
bruno/api_v1/currency/currency.yml
Normal file
20
bruno/api_v1/currency/currency.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
info:
|
||||||
|
name: currency
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{bas_url}}/restricted/currency-rate/{{id}}"
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
runtime:
|
||||||
|
variables:
|
||||||
|
- name: id
|
||||||
|
value: "1"
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
7
bruno/api_v1/currency/folder.yml
Normal file
7
bruno/api_v1/currency/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: currency
|
||||||
|
type: folder
|
||||||
|
seq: 8
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
19
bruno/api_v1/customer/Customer (me).yml
Normal file
19
bruno/api_v1/customer/Customer (me).yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
info:
|
||||||
|
name: Customer (me)
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{bas_url}}/restricted/customer?id=1"
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: "1"
|
||||||
|
type: query
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
19
bruno/api_v1/customer/Customer (other).yml
Normal file
19
bruno/api_v1/customer/Customer (other).yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
info:
|
||||||
|
name: Customer (other)
|
||||||
|
type: http
|
||||||
|
seq: 9
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{bas_url}}/restricted/customer?id=1"
|
||||||
|
params:
|
||||||
|
- name: id
|
||||||
|
value: "1"
|
||||||
|
type: query
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
7
bruno/api_v1/customer/folder.yml
Normal file
7
bruno/api_v1/customer/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: customer
|
||||||
|
type: folder
|
||||||
|
seq: 9
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
15
bruno/api_v1/product/Get Product.yml
Normal file
15
bruno/api_v1/product/Get Product.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
info:
|
||||||
|
name: Get Product
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
http:
|
||||||
|
method: GET
|
||||||
|
url: "{{bas_url}}/restricted/product/200/1/5"
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
7
bruno/api_v1/product/folder.yml
Normal file
7
bruno/api_v1/product/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: product
|
||||||
|
type: folder
|
||||||
|
seq: 7
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -7,12 +7,15 @@ VALUES
|
|||||||
(2, '2022-09-16 17:10:02.852', '2026-03-02 21:24:36.779730', NULL, 'English', 'en', 'en', '__-__-____', '__-__', 0, 1, 1, '🇬🇧'),
|
(2, '2022-09-16 17:10:02.852', '2026-03-02 21:24:36.779730', NULL, 'English', 'en', 'en', '__-__-____', '__-__', 0, 1, 1, '🇬🇧'),
|
||||||
(3, '2022-09-16 17:10:02.852', '2026-03-02 21:24:36.779730', NULL, 'Deutsch', 'de', 'de', '__-__-____', '__-__', 0, 0, 1, '🇩🇪');
|
(3, '2022-09-16 17:10:02.852', '2026-03-02 21:24:36.779730', NULL, 'Deutsch', 'de', 'de', '__-__-____', '__-__', 0, 0, 1, '🇩🇪');
|
||||||
|
|
||||||
|
INSERT INTO `b2b_roles` (`name`, `id`) VALUES ('user','1');
|
||||||
|
INSERT INTO `b2b_roles` (`name`, `id`) VALUES ('admin','2');
|
||||||
|
INSERT INTO `b2b_roles` (`name`, `id`) VALUES ('super_admin','3');
|
||||||
|
|
||||||
|
|
||||||
-- insert sample admin user admin@ma-al.com/Maal12345678
|
-- insert sample admin user admin@ma-al.com/Maal12345678
|
||||||
|
INSERT IGNORE INTO b2b_customers (id, email, password, first_name, last_name, role_id, provider, provider_id, avatar_url, is_active, email_verified, email_verification_token, email_verification_expires, password_reset_token, password_reset_expires, last_password_reset_request, last_login_at, lang_id, country_id, created_at, updated_at, deleted_at)
|
||||||
INSERT IGNORE INTO b2b_customers (id, email, password, first_name, last_name, role, provider, provider_id, avatar_url, is_active, email_verified, email_verification_token, email_verification_expires, password_reset_token, password_reset_expires, last_password_reset_request, last_login_at, lang_id, country_id, created_at, updated_at, deleted_at)
|
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'admin@ma-al.com', '$2a$10$Owy9DjrS0l3Fz4XoOvh5pulgmOMqdwXmb7hYE9BovnSuWS2plGr82', 'Super', 'Admin', 'admin', 'local', '', '', 1, 1, NULL, NULL, '', NULL, NULL, NULL, 1, 1, '2026-03-02 16:55:10.252740', '2026-03-02 16:55:10.252740', NULL);
|
(1, 'admin@ma-al.com', '$2a$10$Owy9DjrS0l3Fz4XoOvh5pulgmOMqdwXmb7hYE9BovnSuWS2plGr82', 'Super', 'Admin', 2, 'local', '', '', 1, 1, NULL, NULL, '', NULL, NULL, NULL, 1, 1, '2026-03-02 16:55:10.252740', '2026-03-02 16:55:10.252740', NULL);
|
||||||
ALTER TABLE b2b_customers AUTO_INCREMENT = 1;
|
ALTER TABLE b2b_customers AUTO_INCREMENT = 1;
|
||||||
|
|
||||||
INSERT INTO `b2b_currencies` (`ps_id_currency`, `is_default`, `is_active`) VALUES
|
INSERT INTO `b2b_currencies` (`ps_id_currency`, `is_default`, `is_active`) VALUES
|
||||||
|
|||||||
Reference in New Issue
Block a user