Merge branch 'main' of ssh://git.ma-al.com:8822/goc_daniel/b2b into order-actions
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/cartsService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/logger"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
@@ -49,6 +50,13 @@ func (h *CartsHandler) AddNewCart(c fiber.Ctx) error {
|
||||
name := c.Query("name")
|
||||
new_cart, err := h.cartsService.CreateNewCart(userID, name)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to create cart",
|
||||
"handler", "CartsHandler.AddNewCart",
|
||||
|
||||
"user_id", userID,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
@@ -72,6 +80,14 @@ func (h *CartsHandler) RemoveCart(c fiber.Ctx) error {
|
||||
|
||||
err = h.cartsService.RemoveCart(userID, uint(cart_id))
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to remove cart",
|
||||
"handler", "CartsHandler.RemoveCart",
|
||||
|
||||
"user_id", userID,
|
||||
"cart_id", cart_id,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
@@ -97,6 +113,14 @@ func (h *CartsHandler) ChangeCartName(c fiber.Ctx) error {
|
||||
|
||||
err = h.cartsService.UpdateCartName(userID, uint(cart_id), new_name)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to update cart name",
|
||||
"handler", "CartsHandler.ChangeCartName",
|
||||
|
||||
"user_id", userID,
|
||||
"cart_id", cart_id,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
@@ -113,6 +137,13 @@ func (h *CartsHandler) RetrieveCartsInfo(c fiber.Ctx) error {
|
||||
|
||||
carts_info, err := h.cartsService.RetrieveCartsInfo(userID)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to retrieve carts info",
|
||||
"handler", "CartsHandler.RetrieveCartsInfo",
|
||||
|
||||
"user_id", userID,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
@@ -136,6 +167,14 @@ func (h *CartsHandler) RetrieveCart(c fiber.Ctx) error {
|
||||
|
||||
cart, err := h.cartsService.RetrieveCart(userID, uint(cart_id))
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to retrieve cart",
|
||||
"handler", "CartsHandler.RetrieveCart",
|
||||
|
||||
"user_id", userID,
|
||||
"cart_id", cart_id,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
@@ -195,6 +234,15 @@ func (h *CartsHandler) AddProduct(c fiber.Ctx) error {
|
||||
|
||||
err = h.cartsService.AddProduct(userID, uint(cart_id), uint(product_id), product_attribute_id, amount, set_amount)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to add product to cart",
|
||||
"handler", "CartsHandler.AddProduct",
|
||||
|
||||
"user_id", userID,
|
||||
"cart_id", cart_id,
|
||||
"product_id", product_id,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
@@ -240,6 +288,15 @@ func (h *CartsHandler) RemoveProduct(c fiber.Ctx) error {
|
||||
|
||||
err = h.cartsService.RemoveProduct(userID, uint(cart_id), uint(product_id), product_attribute_id)
|
||||
if err != nil {
|
||||
|
||||
logger.Error("failed to remove product from cart",
|
||||
"handler", "CartsHandler.RemoveProduct",
|
||||
|
||||
"user_id", userID,
|
||||
"cart_id", cart_id,
|
||||
"product_id", product_id,
|
||||
"error", err.Error(),
|
||||
)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user