ListTaskExecutionLogs
This commit is contained in:
@@ -174,3 +174,76 @@ func NewListPlanExecutionLogResponse(data []models.PlanExecutionLog, total int64
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// --- TaskExecutionLog ---
|
||||
|
||||
// ListTaskExecutionLogRequest 定义了获取任务执行日志列表的请求参数
|
||||
type ListTaskExecutionLogRequest struct {
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"pageSize,default=10"`
|
||||
PlanExecutionLogID *uint `form:"plan_execution_log_id"`
|
||||
TaskID *int `form:"task_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"`
|
||||
}
|
||||
|
||||
// TaskDTO 是用于API响应的简化版任务结构
|
||||
type TaskDTO struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// TaskExecutionLogDTO 是用于API响应的任务执行日志结构
|
||||
type TaskExecutionLogDTO struct {
|
||||
ID uint `json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
PlanExecutionLogID uint `json:"plan_execution_log_id"`
|
||||
TaskID int `json:"task_id"`
|
||||
Task TaskDTO `json:"task"` // 嵌套的任务信息
|
||||
Status models.ExecutionStatus `json:"status"`
|
||||
Output string `json:"output"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
EndedAt time.Time `json:"ended_at"`
|
||||
}
|
||||
|
||||
// ListTaskExecutionLogResponse 是获取任务执行日志列表的响应结构
|
||||
type ListTaskExecutionLogResponse struct {
|
||||
List []TaskExecutionLogDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// NewListTaskExecutionLogResponse 从模型数据创建列表响应 DTO
|
||||
func NewListTaskExecutionLogResponse(data []models.TaskExecutionLog, total int64, page, pageSize int) *ListTaskExecutionLogResponse {
|
||||
dtos := make([]TaskExecutionLogDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = TaskExecutionLogDTO{
|
||||
ID: item.ID,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
PlanExecutionLogID: item.PlanExecutionLogID,
|
||||
TaskID: item.TaskID,
|
||||
Task: TaskDTO{
|
||||
ID: uint(item.Task.ID),
|
||||
Name: item.Task.Name,
|
||||
Description: item.Task.Description,
|
||||
},
|
||||
Status: item.Status,
|
||||
Output: item.Output,
|
||||
StartedAt: item.StartedAt,
|
||||
EndedAt: item.EndedAt,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListTaskExecutionLogResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user