ListPigPurchases
This commit is contained in:
@@ -2,6 +2,7 @@ package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
||||
)
|
||||
@@ -423,3 +424,32 @@ func NewListPigSickLogResponse(data []models.PigSickLog, total int64, page, page
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewListPigPurchaseResponse 从模型数据创建列表响应 DTO
|
||||
func NewListPigPurchaseResponse(data []models.PigPurchase, total int64, page, pageSize int) *ListPigPurchaseResponse {
|
||||
dtos := make([]PigPurchaseDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = PigPurchaseDTO{
|
||||
ID: item.ID,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
PigBatchID: item.PigBatchID,
|
||||
PurchaseDate: item.PurchaseDate,
|
||||
Supplier: item.Supplier,
|
||||
Quantity: item.Quantity,
|
||||
UnitPrice: item.UnitPrice,
|
||||
TotalPrice: item.TotalPrice,
|
||||
Remarks: item.Remarks,
|
||||
OperatorID: item.OperatorID,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListPigPurchaseResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user