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