mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 07:36:37 +08:00
修复任务参数类型转换
This commit is contained in:
@@ -187,7 +187,7 @@ func RetryTask(c *gin.Context) {
|
||||
switch {
|
||||
case strings.Contains(errMsg, "不存在"):
|
||||
c.JSON(http.StatusNotFound, util.Err(errMsg))
|
||||
case strings.Contains(errMsg, "只有非进行中") || strings.Contains(errMsg, "不支持重试") || strings.Contains(errMsg, "已达到最大重试"):
|
||||
case strings.Contains(errMsg, "只有失败的任务") || strings.Contains(errMsg, "不支持重试") || strings.Contains(errMsg, "已达到最大重试"):
|
||||
c.JSON(http.StatusBadRequest, util.Err(errMsg))
|
||||
default:
|
||||
c.JSON(http.StatusInternalServerError, util.Err(fmt.Sprintf("%s: %v", TaskRetryFailed, err)))
|
||||
|
||||
@@ -31,7 +31,7 @@ const defaultMaxRetry = 3
|
||||
type TaskParam struct {
|
||||
Name string `json:"Name"` // 参数键名
|
||||
Label string `json:"Label"` // 显示名称
|
||||
Type string `json:"Type"` // 类型:string, text, number
|
||||
Type string `json:"Type"` // 类型:string, text, number, boolean
|
||||
Required bool `json:"Required"` // 是否必填
|
||||
Placeholder string `json:"Placeholder"` // 占位符
|
||||
Description string `json:"Description"` // 描述
|
||||
|
||||
@@ -8,7 +8,7 @@ const (
|
||||
errCreateTaskExecutionFailed = "创建任务执行记录失败: %w"
|
||||
errTaskEnqueueFailed = "任务入队失败: %w"
|
||||
errTaskExecutionNotFound = "任务执行记录不存在: %w"
|
||||
errRetryOnlyFinishedTask = "只有非进行中的任务才能重试,当前状态: %s"
|
||||
errRetryOnlyFailedTask = "只有失败的任务才能重试,当前状态: %s"
|
||||
errTaskNotRetryable = "该任务不支持重试"
|
||||
errTaskMaxRetryExceeded = "已达到最大重试次数 %d"
|
||||
errCreateRetryExecutionFailed = "创建重试任务执行记录失败: %w"
|
||||
|
||||
@@ -138,8 +138,8 @@ func RetryTask(ctx context.Context, id uint64) (string, error) {
|
||||
return "", fmt.Errorf(errTaskExecutionNotFound, err)
|
||||
}
|
||||
|
||||
if execution.Status == model.TaskExecutionStatusPending || execution.Status == model.TaskExecutionStatusRunning {
|
||||
return "", fmt.Errorf(errRetryOnlyFinishedTask, execution.Status)
|
||||
if execution.Status != model.TaskExecutionStatusFailed {
|
||||
return "", fmt.Errorf(errRetryOnlyFailedTask, execution.Status)
|
||||
}
|
||||
|
||||
if !execution.Retryable {
|
||||
|
||||
Reference in New Issue
Block a user