add product ingredients

This commit is contained in:
Aditya Siregar
2025-09-12 15:37:19 +07:00
parent efe09c21e4
commit 3a04990ec8
35 changed files with 2572 additions and 357 deletions
@@ -152,3 +152,27 @@ func UnitModelResponseToResponse(model *models.UnitResponse) contract.UnitRespon
}
}
func IngredientUnitsModelResponseToResponse(model *models.IngredientUnitsResponse) contract.IngredientUnitsResponse {
if model == nil {
return contract.IngredientUnitsResponse{}
}
response := contract.IngredientUnitsResponse{
IngredientID: model.IngredientID,
IngredientName: model.IngredientName,
BaseUnitID: model.BaseUnitID,
BaseUnitName: model.BaseUnitName,
Units: make([]*contract.UnitResponse, 0),
}
// Map units
for _, unit := range model.Units {
if unit != nil {
unitResp := UnitModelResponseToResponse(unit)
response.Units = append(response.Units, &unitResp)
}
}
return response
}