feat: 任务功能性能及接口优化

This commit is contained in:
tbphp
2025-07-05 17:19:20 +08:00
parent 2edd48d0c1
commit c40ee7cb5b
7 changed files with 135 additions and 129 deletions

View File

@@ -1,31 +1,18 @@
package handler
import (
"gpt-load/internal/response"
app_errors "gpt-load/internal/errors"
"gpt-load/internal/response"
"github.com/gin-gonic/gin"
)
// GetTaskStatus handles requests for the status of the global long-running task.
func (s *Server) GetTaskStatus(c *gin.Context) {
taskStatus := s.TaskService.GetTaskStatus()
taskStatus, err := s.TaskService.GetTaskStatus()
if err != nil {
response.Error(c, app_errors.NewAPIError(app_errors.ErrInternalServer, "Failed to get task status"))
return
}
response.Success(c, taskStatus)
}
// GetTaskResult handles requests for the result of a finished task.
func (s *Server) GetTaskResult(c *gin.Context) {
taskID := c.Param("task_id")
if taskID == "" {
response.Error(c, app_errors.NewAPIError(app_errors.ErrBadRequest, "Task ID is required"))
return
}
result, found := s.TaskService.GetResult(taskID)
if !found {
response.Error(c, app_errors.ErrResourceNotFound)
return
}
response.Success(c, result)
}