ListPlanExecutionLogs
This commit is contained in:
@@ -117,3 +117,60 @@ func NewListDeviceCommandLogResponse(data []models.DeviceCommandLog, total int64
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// --- PlanExecutionLog ---
|
||||
|
||||
// ListPlanExecutionLogRequest 定义了获取计划执行日志列表的请求参数
|
||||
type ListPlanExecutionLogRequest struct {
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"pageSize,default=10"`
|
||||
PlanID *uint `form:"plan_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"`
|
||||
}
|
||||
|
||||
// PlanExecutionLogDTO 是用于API响应的计划执行日志结构
|
||||
type PlanExecutionLogDTO struct {
|
||||
ID uint `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
PlanID uint `json:"plan_id"`
|
||||
Status models.ExecutionStatus `json:"status"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
EndedAt time.Time `json:"ended_at"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// ListPlanExecutionLogResponse 是获取计划执行日志列表的响应结构
|
||||
type ListPlanExecutionLogResponse struct {
|
||||
List []PlanExecutionLogDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// NewListPlanExecutionLogResponse 从模型数据创建列表响应 DTO
|
||||
func NewListPlanExecutionLogResponse(data []models.PlanExecutionLog, total int64, page, pageSize int) *ListPlanExecutionLogResponse {
|
||||
dtos := make([]PlanExecutionLogDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = PlanExecutionLogDTO{
|
||||
ID: item.ID,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
PlanID: item.PlanID,
|
||||
Status: item.Status,
|
||||
StartedAt: item.StartedAt,
|
||||
EndedAt: item.EndedAt,
|
||||
Error: item.Error,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListPlanExecutionLogResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user