ListPigTransferLogs
This commit is contained in:
@@ -362,3 +362,33 @@ func NewListWeighingRecordResponse(data []models.WeighingRecord, total int64, pa
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewListPigTransferLogResponse 从模型数据创建列表响应 DTO
|
||||
func NewListPigTransferLogResponse(data []models.PigTransferLog, total int64, page, pageSize int) *ListPigTransferLogResponse {
|
||||
dtos := make([]PigTransferLogDTO, len(data))
|
||||
for i, item := range data {
|
||||
// 注意:PigTransferLog 的 ID, CreatedAt, UpdatedAt 字段是 gorm.Model 嵌入的
|
||||
dtos[i] = PigTransferLogDTO{
|
||||
ID: item.ID,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
TransferTime: item.TransferTime,
|
||||
PigBatchID: item.PigBatchID,
|
||||
PenID: item.PenID,
|
||||
Quantity: item.Quantity,
|
||||
Type: item.Type,
|
||||
CorrelationID: item.CorrelationID,
|
||||
OperatorID: item.OperatorID,
|
||||
Remarks: item.Remarks,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListPigTransferLogResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,3 +460,40 @@ type ListWeighingRecordResponse struct {
|
||||
List []WeighingRecordDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// --- PigTransferLog ---
|
||||
|
||||
// ListPigTransferLogRequest 定义了获取猪只迁移日志列表的请求参数
|
||||
type ListPigTransferLogRequest struct {
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"pageSize,default=10"`
|
||||
PigBatchID *uint `form:"pig_batch_id"`
|
||||
PenID *uint `form:"pen_id"`
|
||||
TransferType *string `form:"transfer_type"`
|
||||
OperatorID *uint `form:"operator_id"`
|
||||
CorrelationID *string `form:"correlation_id"`
|
||||
StartTime *time.Time `form:"start_time" time_format:"rfc3339"`
|
||||
EndTime *time.Time `form:"end_time" time_format:"rfc3339"`
|
||||
OrderBy string `form:"order_by"`
|
||||
}
|
||||
|
||||
// PigTransferLogDTO 是用于API响应的猪只迁移日志结构
|
||||
type PigTransferLogDTO struct {
|
||||
ID uint `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
TransferTime time.Time `json:"transfer_time"`
|
||||
PigBatchID uint `json:"pig_batch_id"`
|
||||
PenID uint `json:"pen_id"`
|
||||
Quantity int `json:"quantity"`
|
||||
Type models.PigTransferType `json:"type"`
|
||||
CorrelationID string `json:"correlation_id"`
|
||||
OperatorID uint `json:"operator_id"`
|
||||
Remarks string `json:"remarks"`
|
||||
}
|
||||
|
||||
// ListPigTransferLogResponse 是获取猪只迁移日志列表的响应结构
|
||||
type ListPigTransferLogResponse struct {
|
||||
List []PigTransferLogDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user