ListPendingCollections
This commit is contained in:
@@ -247,3 +247,56 @@ func NewListTaskExecutionLogResponse(data []models.TaskExecutionLog, total int64
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// --- PendingCollection ---
|
||||
|
||||
// ListPendingCollectionRequest 定义了获取待采集请求列表的请求参数
|
||||
type ListPendingCollectionRequest struct {
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"pageSize,default=10"`
|
||||
DeviceID *uint `form:"device_id"`
|
||||
Status *string `form:"status"`
|
||||
StartTime *time.Time `form:"start_time" time_format:"rfc3339"`
|
||||
EndTime *time.Time `form:"end_time" time_format:"rfc3339"`
|
||||
OrderBy string `form:"order_by"`
|
||||
}
|
||||
|
||||
// PendingCollectionDTO 是用于API响应的待采集请求结构
|
||||
type PendingCollectionDTO struct {
|
||||
CorrelationID string `json:"correlation_id"`
|
||||
DeviceID uint `json:"device_id"`
|
||||
CommandMetadata models.UintArray `json:"command_metadata"`
|
||||
Status models.PendingCollectionStatus `json:"status"`
|
||||
FulfilledAt *time.Time `json:"fulfilled_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ListPendingCollectionResponse 是获取待采集请求列表的响应结构
|
||||
type ListPendingCollectionResponse struct {
|
||||
List []PendingCollectionDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// NewListPendingCollectionResponse 从模型数据创建列表响应 DTO
|
||||
func NewListPendingCollectionResponse(data []models.PendingCollection, total int64, page, pageSize int) *ListPendingCollectionResponse {
|
||||
dtos := make([]PendingCollectionDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = PendingCollectionDTO{
|
||||
CorrelationID: item.CorrelationID,
|
||||
DeviceID: item.DeviceID,
|
||||
CommandMetadata: item.CommandMetadata,
|
||||
Status: item.Status,
|
||||
FulfilledAt: item.FulfilledAt,
|
||||
CreatedAt: item.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListPendingCollectionResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user