mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 15:25:43 +00:00
feat/BE/US-76/TASK-122,133,121,120 Recording add create delete edit
This commit is contained in:
@@ -48,17 +48,27 @@ type RecordingBodyWeightDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RecordingDepletionDTO struct {
|
type RecordingDepletionDTO struct {
|
||||||
ProductWarehouseId uint `json:"product_warehouse_id"`
|
ProductWarehouseId uint `json:"product_warehouse_id"`
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
Notes *string `json:"notes,omitempty"`
|
Notes *string `json:"notes,omitempty"`
|
||||||
|
ProductWarehouse *RecordingProductWarehouseDTO `json:"product_warehouse,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecordingStockDTO struct {
|
type RecordingStockDTO struct {
|
||||||
ProductWarehouseId uint `json:"product_warehouse_id"`
|
ProductWarehouseId uint `json:"product_warehouse_id"`
|
||||||
Increase *float64 `json:"increase,omitempty"`
|
Increase *float64 `json:"increase,omitempty"`
|
||||||
Decrease *float64 `json:"decrease,omitempty"`
|
Decrease *float64 `json:"decrease,omitempty"`
|
||||||
UsageAmount *int64 `json:"usage_amount,omitempty"`
|
UsageAmount *int64 `json:"usage_amount,omitempty"`
|
||||||
Notes *string `json:"notes,omitempty"`
|
Notes *string `json:"notes,omitempty"`
|
||||||
|
ProductWarehouse *RecordingProductWarehouseDTO `json:"product_warehouse,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecordingProductWarehouseDTO struct {
|
||||||
|
Id uint `json:"id"`
|
||||||
|
ProductId uint `json:"product_id"`
|
||||||
|
ProductName string `json:"product_name"`
|
||||||
|
WarehouseId uint `json:"warehouse_id"`
|
||||||
|
WarehouseName string `json:"warehouse_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Mapper Functions ===
|
// === Mapper Functions ===
|
||||||
@@ -145,6 +155,7 @@ func ToRecordingDepletionDTOs(depletions []entity.RecordingDepletion) []Recordin
|
|||||||
ProductWarehouseId: d.ProductWarehouseId,
|
ProductWarehouseId: d.ProductWarehouseId,
|
||||||
Total: d.Total,
|
Total: d.Total,
|
||||||
Notes: d.Notes,
|
Notes: d.Notes,
|
||||||
|
ProductWarehouse: toRecordingProductWarehouseDTO(&d.ProductWarehouse),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -159,7 +170,29 @@ func ToRecordingStockDTOs(stocks []entity.RecordingStock) []RecordingStockDTO {
|
|||||||
Decrease: s.Decrease,
|
Decrease: s.Decrease,
|
||||||
UsageAmount: s.UsageAmount,
|
UsageAmount: s.UsageAmount,
|
||||||
Notes: s.Notes,
|
Notes: s.Notes,
|
||||||
|
ProductWarehouse: toRecordingProductWarehouseDTO(&s.ProductWarehouse),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func toRecordingProductWarehouseDTO(pw *entity.ProductWarehouse) *RecordingProductWarehouseDTO {
|
||||||
|
if pw == nil || pw.Id == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
dto := RecordingProductWarehouseDTO{
|
||||||
|
Id: pw.Id,
|
||||||
|
ProductId: pw.ProductId,
|
||||||
|
WarehouseId: pw.WarehouseId,
|
||||||
|
}
|
||||||
|
|
||||||
|
if pw.Product.Id != 0 {
|
||||||
|
dto.ProductName = pw.Product.Name
|
||||||
|
}
|
||||||
|
if pw.Warehouse.Id != 0 {
|
||||||
|
dto.WarehouseName = pw.Warehouse.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
return &dto
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user