add total out
This commit is contained in:
@@ -238,6 +238,34 @@ func (h *InventoryHandler) AdjustInventory(c *gin.Context) {
|
||||
util.HandleResponse(c.Writer, c.Request, inventoryResponse, "InventoryHandler::AdjustInventory")
|
||||
}
|
||||
|
||||
func (h *InventoryHandler) RestockInventory(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
var req contract.RestockInventoryRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
logger.FromContext(c.Request.Context()).WithError(err).Error("InventoryHandler::RestockInventory -> request binding failed")
|
||||
validationResponseError := contract.NewResponseError(constants.MissingFieldErrorCode, constants.RequestEntity, err.Error())
|
||||
util.HandleResponse(c.Writer, c.Request, contract.BuildErrorResponse([]*contract.ResponseError{validationResponseError}), "InventoryHandler::RestockInventory")
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Add validation for restock request
|
||||
// validationError, validationErrorCode := h.inventoryValidator.ValidateRestockInventoryRequest(&req)
|
||||
// if validationError != nil {
|
||||
// validationResponseError := contract.NewResponseError(validationErrorCode, constants.RequestEntity, validationError.Error())
|
||||
// util.HandleResponse(c.Writer, c.Request, contract.BuildErrorResponse([]*contract.ResponseError{validationResponseError}), "InventoryHandler::RestockInventory")
|
||||
// return
|
||||
// }
|
||||
|
||||
inventoryResponse := h.inventoryService.RestockInventory(ctx, &req)
|
||||
if inventoryResponse.HasErrors() {
|
||||
errorResp := inventoryResponse.GetErrors()[0]
|
||||
logger.FromContext(ctx).WithError(errorResp).Error("InventoryHandler::RestockInventory -> Failed to restock inventory from service")
|
||||
}
|
||||
|
||||
util.HandleResponse(c.Writer, c.Request, inventoryResponse, "InventoryHandler::RestockInventory")
|
||||
}
|
||||
|
||||
func (h *InventoryHandler) GetLowStockItems(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user