feat: add endpoints for retrieving stock alerts and anomaly items, including database queries and models

This commit is contained in:
Tran Anh Tuan
2026-05-13 18:10:34 +07:00
parent 383bed757d
commit 0a56dfeb61
11 changed files with 695 additions and 0 deletions

View File

@@ -32,3 +32,29 @@ func ToDomainContainerStats(r db.GetContainerStatsRow) models.ContainerStats {
EmptyContainers: int64(r.EmptyContainers),
}
}
func ToDomainStockAlert(r db.GetStockAlertsRow) models.StockAlert {
return models.StockAlert{
ID: r.ID,
Name: r.Name,
Unit: r.Unit,
TotalQuantity: r.TotalQuantity,
MinQuantity: r.MinQuantity,
ComponentTypeID: r.ComponentTypeID,
ComponentTypeName: r.ComponentTypeName.String,
}
}
func ToDomainAnomalyItem(r db.GetAnomalyItemsRow) models.AnomalyItem {
return models.AnomalyItem{
ID: r.ID,
ComponentID: r.ComponentID,
ContainerID: r.ContainerID,
Quantity: r.Quantity,
Status: string(r.Status),
CreatedAt: r.CreatedAt,
UpdatedAt: r.UpdatedAt,
ComponentName: r.ComponentName,
ComponentUnit: r.ComponentUnit,
}
}