Merge branch 'main' of ssh://git.ma-al.com:8822/goc_daniel/b2b into product-procedures

This commit is contained in:
2026-03-27 08:47:41 +01:00
25 changed files with 614 additions and 729 deletions

View File

@@ -28,6 +28,7 @@ func MeiliSearchHandlerRoutes(r fiber.Router) fiber.Router {
// for testing purposes only. Must be removed before proper release.
r.Get("/create-index", handler.CreateIndex)
r.Get("/test", handler.Test)
r.Get("/settings", handler.GetSettings)
// for all users
r.Get("/search", handler.Search)
@@ -77,13 +78,6 @@ func (h *MeiliSearchHandler) Search(c fiber.Ctx) error {
query := c.Query("query")
limit_attribute := c.Query("limit")
limit, err := strconv.Atoi(limit_attribute)
if err != nil {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
id_category_attribute := c.Query("id_category", "0")
id_category, err := strconv.Atoi(id_category_attribute)
if err != nil {
@@ -91,21 +85,7 @@ func (h *MeiliSearchHandler) Search(c fiber.Ctx) error {
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
price_lower_bound_attribute := c.Query("price_lower_bound", "-1.0")
price_lower_bound, err := strconv.ParseFloat(price_lower_bound_attribute, 64)
if err != nil {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
price_upper_bound_attribute := c.Query("price_upper_bound", "-1.0")
price_upper_bound, err := strconv.ParseFloat(price_upper_bound_attribute, 64)
if err != nil {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
meili_response, err := h.meiliService.Search(id_lang, query, uint(limit), uint(id_category), price_lower_bound, price_upper_bound)
meili_response, err := h.meiliService.Search(id_lang, query, uint(id_category))
if err != nil {
return c.Status(responseErrors.GetErrorStatus(err)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
@@ -113,3 +93,19 @@ func (h *MeiliSearchHandler) Search(c fiber.Ctx) error {
return c.JSON(response.Make(&meili_response, 0, i18n.T_(c, response.Message_OK)))
}
func (h *MeiliSearchHandler) GetSettings(c fiber.Ctx) error {
id_lang, ok := c.Locals("langID").(uint)
if !ok {
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
}
settings, err := h.meiliService.GetIndexSettings(id_lang)
if err != nil {
return c.Status(responseErrors.GetErrorStatus(err)).
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
}
return c.JSON(response.Make(&settings, 0, i18n.T_(c, response.Message_OK)))
}