feat: roles, permissions

This commit is contained in:
2026-04-02 15:06:00 +02:00
parent 6428ddb527
commit 0ed9d792b6
22 changed files with 391 additions and 80 deletions

View File

@@ -1,10 +1,12 @@
package restricted
import (
"fmt"
"strconv"
"git.ma-al.com/goc_daniel/b2b/app/config"
"git.ma-al.com/goc_daniel/b2b/app/service/productService"
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
@@ -30,7 +32,7 @@ func ProductsHandlerRoutes(r fiber.Router) fiber.Router {
handler := NewProductsHandler()
//TODO: WIP doesn't work yet
r.Get("/product/:id/:country_id/:quantity", handler.GetProductJson)
r.Get("/:id/:country_id/:quantity", handler.GetProductJson)
return r
}
@@ -60,19 +62,18 @@ func (h *ProductsHandler) GetProductJson(c fiber.Ctx) error {
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
}
id_lang, ok := c.Locals("lang_id").(int)
p_id_customer, ok := c.Locals(constdata.USER_LOCALES_ID).(uint)
if !ok {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
p_id_customer, ok := c.Locals("user_id").(int)
fmt.Printf("p_id_customer: %v\n", p_id_customer)
id_lang, ok := c.Locals(constdata.LANG_LOCALES_ID).(uint)
if !ok {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
productJson, err := h.productService.GetJSON(p_id_product, id_lang, p_id_customer, b2b_id_country, p_quantity)
productJson, err := h.productService.GetJSON(p_id_product, int(id_lang), int(p_id_customer), b2b_id_country, p_quantity)
if err != nil {
return c.Status(responseErrors.GetErrorStatus(err)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))