ListWeighingRecords
This commit is contained in:
@@ -335,3 +335,30 @@ func NewListWeighingBatchResponse(data []models.WeighingBatch, total int64, page
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewListWeighingRecordResponse 从模型数据创建列表响应 DTO
|
||||
func NewListWeighingRecordResponse(data []models.WeighingRecord, total int64, page, pageSize int) *ListWeighingRecordResponse {
|
||||
dtos := make([]WeighingRecordDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = WeighingRecordDTO{
|
||||
ID: item.ID,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
Weight: item.Weight,
|
||||
WeighingBatchID: item.WeighingBatchID,
|
||||
PenID: item.PenID,
|
||||
OperatorID: item.OperatorID,
|
||||
Remark: item.Remark,
|
||||
WeighingTime: item.WeighingTime,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListWeighingRecordResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,3 +427,36 @@ type ListWeighingBatchResponse struct {
|
||||
List []WeighingBatchDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// --- WeighingRecord ---
|
||||
|
||||
// ListWeighingRecordRequest 定义了获取单次称重记录列表的请求参数
|
||||
type ListWeighingRecordRequest struct {
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"pageSize,default=10"`
|
||||
WeighingBatchID *uint `form:"weighing_batch_id"`
|
||||
PenID *uint `form:"pen_id"`
|
||||
OperatorID *uint `form:"operator_id"`
|
||||
StartTime *time.Time `form:"start_time" time_format:"rfc3339"`
|
||||
EndTime *time.Time `form:"end_time" time_format:"rfc3339"`
|
||||
OrderBy string `form:"order_by"`
|
||||
}
|
||||
|
||||
// WeighingRecordDTO 是用于API响应的单次称重记录结构
|
||||
type WeighingRecordDTO struct {
|
||||
ID uint `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Weight float64 `json:"weight"`
|
||||
WeighingBatchID uint `json:"weighing_batch_id"`
|
||||
PenID uint `json:"pen_id"`
|
||||
OperatorID uint `json:"operator_id"`
|
||||
Remark string `json:"remark"`
|
||||
WeighingTime time.Time `json:"weighing_time"`
|
||||
}
|
||||
|
||||
// ListWeighingRecordResponse 是获取单次称重记录列表的响应结构
|
||||
type ListWeighingRecordResponse struct {
|
||||
List []WeighingRecordDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user