feat: 任务功能性能及接口优化
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user