增加最后一次操作类型

This commit is contained in:
2025-11-27 18:32:22 +08:00
parent 3b12802900
commit 33cdf7278e
6 changed files with 74 additions and 14 deletions

View File

@@ -14,17 +14,20 @@ func ConvertCurrentStockToDTO(material *models.RawMaterial, latestLog *models.Ra
stock := float32(0)
lastUpdated := material.CreatedAt.Format(time.RFC3339) // 默认使用创建时间
var lastOperationSourceType models.StockLogSourceType
if latestLog != nil {
stock = latestLog.AfterQuantity
lastUpdated = latestLog.HappenedAt.Format(time.RFC3339)
lastOperationSourceType = latestLog.SourceType
}
return &CurrentStockResponse{
RawMaterialID: material.ID,
RawMaterialName: material.Name,
Stock: stock,
LastUpdated: lastUpdated,
RawMaterialID: material.ID,
RawMaterialName: material.Name,
Stock: stock,
LastUpdated: lastUpdated,
LastOperationSourceType: lastOperationSourceType,
}
}