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