some debugging
This commit is contained in:
@@ -40,7 +40,6 @@ func AuthHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
r.Post("/reset-password", handler.ResetPassword)
|
||||
r.Post("/logout", handler.Logout)
|
||||
r.Post("/refresh", handler.RefreshToken)
|
||||
r.Post("/update-choice", handler.UpdateJWTToken)
|
||||
|
||||
// Google OAuth2
|
||||
r.Get("/google", handler.GoogleLogin)
|
||||
@@ -48,6 +47,7 @@ func AuthHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
|
||||
authProtected := r.Group("", middleware.AuthMiddleware())
|
||||
authProtected.Get("/me", handler.Me)
|
||||
authProtected.Post("/update-choice", handler.UpdateJWTToken)
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -345,9 +345,9 @@ func (h *AuthHandler) CompleteRegistration(c fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusCreated).JSON(response)
|
||||
}
|
||||
|
||||
// CompleteRegistration handles completion of registration with password
|
||||
// Updates JWT Tokens
|
||||
func (h *AuthHandler) UpdateJWTToken(c fiber.Ctx) error {
|
||||
return h.UpdateJWTToken(c)
|
||||
return h.authService.UpdateJWTToken(c)
|
||||
}
|
||||
|
||||
// GoogleLogin redirects the user to Google's OAuth2 consent page
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewMeiliSearchHandler() *MeiliSearchHandler {
|
||||
func MeiliSearchHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewMeiliSearchHandler()
|
||||
|
||||
// for superadmin only
|
||||
// for testing purposes only. Must be removed before proper release.
|
||||
r.Get("/create-index", handler.CreateIndex)
|
||||
r.Get("/test", handler.Test)
|
||||
|
||||
@@ -84,32 +84,32 @@ func (h *MeiliSearchHandler) Search(c fiber.Ctx) error {
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
id_category_attribute := c.Query("id_category")
|
||||
id_category_attribute := c.Query("id_category", "0")
|
||||
id_category, err := strconv.Atoi(id_category_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
price_lower_bound_attribute := c.Query("price_lower_bound")
|
||||
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")
|
||||
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)))
|
||||
}
|
||||
|
||||
test, 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(limit), uint(id_category), price_lower_bound, price_upper_bound)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&test, 0, i18n.T_(c, response.Message_OK)))
|
||||
return c.JSON(response.Make(&meili_response, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/productDescriptionService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/productTranslationService"
|
||||
"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"
|
||||
@@ -13,24 +13,24 @@ import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// ProductDescriptionHandler handles endpoints that receive, save and translate product descriptions.
|
||||
type ProductDescriptionHandler struct {
|
||||
productDescriptionService *productDescriptionService.ProductDescriptionService
|
||||
// ProductTranslationHandler handles endpoints that receive, save and translate product descriptions.
|
||||
type ProductTranslationHandler struct {
|
||||
productTranslationService *productTranslationService.ProductTranslationService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
// NewProductDescriptionHandler creates a new ProductDescriptionHandler instance
|
||||
func NewProductDescriptionHandler() *ProductDescriptionHandler {
|
||||
productDescriptionService := productDescriptionService.New()
|
||||
return &ProductDescriptionHandler{
|
||||
productDescriptionService: productDescriptionService,
|
||||
// NewProductTranslationHandler creates a new ProductTranslationHandler instance
|
||||
func NewProductTranslationHandler() *ProductTranslationHandler {
|
||||
productTranslationService := productTranslationService.New()
|
||||
return &ProductTranslationHandler{
|
||||
productTranslationService: productTranslationService,
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
// ProductDescriptionRoutes registers all product description routes
|
||||
func ProductDescriptionHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewProductDescriptionHandler()
|
||||
// ProductTranslationRoutes registers all product description routes
|
||||
func ProductTranslationHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewProductTranslationHandler()
|
||||
|
||||
r.Get("/get-product-description", handler.GetProductDescription)
|
||||
r.Post("/save-product-description", handler.SaveProductDescription)
|
||||
@@ -40,7 +40,7 @@ func ProductDescriptionHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
}
|
||||
|
||||
// GetProductDescription returns the product description for a given product ID
|
||||
func (h *ProductDescriptionHandler) GetProductDescription(c fiber.Ctx) error {
|
||||
func (h *ProductTranslationHandler) GetProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
@@ -61,7 +61,7 @@ func (h *ProductDescriptionHandler) GetProductDescription(c fiber.Ctx) error {
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
description, err := h.productDescriptionService.GetProductDescription(userID, uint(productID), uint(productLangID))
|
||||
description, err := h.productTranslationService.GetProductDescription(userID, uint(productID), uint(productLangID))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
@@ -71,7 +71,7 @@ func (h *ProductDescriptionHandler) GetProductDescription(c fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// SaveProductDescription saves the description for a given product ID, in given language
|
||||
func (h *ProductDescriptionHandler) SaveProductDescription(c fiber.Ctx) error {
|
||||
func (h *ProductTranslationHandler) SaveProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
@@ -98,7 +98,7 @@ func (h *ProductDescriptionHandler) SaveProductDescription(c fiber.Ctx) error {
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
err = h.productDescriptionService.SaveProductDescription(userID, uint(productID), uint(productLangID), updates)
|
||||
err = h.productTranslationService.SaveProductDescription(userID, uint(productID), uint(productLangID), updates)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
@@ -108,7 +108,7 @@ func (h *ProductDescriptionHandler) SaveProductDescription(c fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// TranslateProductDescription returns translated product description
|
||||
func (h *ProductDescriptionHandler) TranslateProductDescription(c fiber.Ctx) error {
|
||||
func (h *ProductTranslationHandler) TranslateProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
@@ -142,7 +142,7 @@ func (h *ProductDescriptionHandler) TranslateProductDescription(c fiber.Ctx) err
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
description, err := h.productDescriptionService.TranslateProductDescription(userID, uint(productID), uint(productFromLangID), uint(productToLangID), aiModel)
|
||||
description, err := h.productTranslationService.TranslateProductDescription(userID, uint(productID), uint(productFromLangID), uint(productToLangID), aiModel)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
Reference in New Issue
Block a user