Compare commits
No commits in common. "9e74d415b3dfb9c6f85610f899a8994e871f31dd" and "4cade376b90bda29c3779f55349d672254abe65f" have entirely different histories.
9e74d415b3
...
4cade376b9
@ -138,14 +138,13 @@ func (h *InventoryHandler) GetInventory(c *gin.Context) {
|
|||||||
|
|
||||||
func (h *InventoryHandler) ListInventory(c *gin.Context) {
|
func (h *InventoryHandler) ListInventory(c *gin.Context) {
|
||||||
ctx := c.Request.Context()
|
ctx := c.Request.Context()
|
||||||
contextInfo := appcontext.FromGinContext(ctx)
|
|
||||||
|
|
||||||
req := &contract.ListInventoryRequest{
|
req := &contract.ListInventoryRequest{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
Limit: 10,
|
Limit: 10,
|
||||||
OutletID: &contextInfo.OutletID,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse query parameters
|
||||||
if pageStr := c.Query("page"); pageStr != "" {
|
if pageStr := c.Query("page"); pageStr != "" {
|
||||||
if page, err := strconv.Atoi(pageStr); err == nil {
|
if page, err := strconv.Atoi(pageStr); err == nil {
|
||||||
req.Page = page
|
req.Page = page
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package mappers
|
|||||||
import (
|
import (
|
||||||
"apskel-pos-be/internal/entities"
|
"apskel-pos-be/internal/entities"
|
||||||
"apskel-pos-be/internal/models"
|
"apskel-pos-be/internal/models"
|
||||||
"github.com/google/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func InventoryEntityToModel(entity *entities.Inventory) *models.Inventory {
|
func InventoryEntityToModel(entity *entities.Inventory) *models.Inventory {
|
||||||
@ -54,16 +53,10 @@ func InventoryEntityToResponse(entity *entities.Inventory) *models.InventoryResp
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
productName := ""
|
|
||||||
if entity.Product.ID != uuid.Nil {
|
|
||||||
productName = entity.Product.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
return &models.InventoryResponse{
|
return &models.InventoryResponse{
|
||||||
ID: entity.ID,
|
ID: entity.ID,
|
||||||
OutletID: entity.OutletID,
|
OutletID: entity.OutletID,
|
||||||
ProductID: entity.ProductID,
|
ProductID: entity.ProductID,
|
||||||
ProductName: productName,
|
|
||||||
Quantity: entity.Quantity,
|
Quantity: entity.Quantity,
|
||||||
ReorderLevel: entity.ReorderLevel,
|
ReorderLevel: entity.ReorderLevel,
|
||||||
IsLowStock: entity.IsLowStock(),
|
IsLowStock: entity.IsLowStock(),
|
||||||
|
|||||||
@ -36,7 +36,6 @@ type InventoryResponse struct {
|
|||||||
ID uuid.UUID
|
ID uuid.UUID
|
||||||
OutletID uuid.UUID
|
OutletID uuid.UUID
|
||||||
ProductID uuid.UUID
|
ProductID uuid.UUID
|
||||||
ProductName string
|
|
||||||
Quantity int
|
Quantity int
|
||||||
ReorderLevel int
|
ReorderLevel int
|
||||||
IsLowStock bool
|
IsLowStock bool
|
||||||
|
|||||||
@ -43,10 +43,6 @@ func InventoryModelResponseToResponse(inv *models.InventoryResponse) *contract.I
|
|||||||
ReorderLevel: inv.ReorderLevel,
|
ReorderLevel: inv.ReorderLevel,
|
||||||
IsLowStock: inv.IsLowStock,
|
IsLowStock: inv.IsLowStock,
|
||||||
UpdatedAt: inv.UpdatedAt,
|
UpdatedAt: inv.UpdatedAt,
|
||||||
Product: &contract.ProductResponse{
|
|
||||||
ID: inv.ProductID,
|
|
||||||
Name: inv.ProductName,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user