refactor(task): 重构任务服务和数据结构

This commit is contained in:
2026-06-12 15:29:05 +08:00
parent 1c6c9bae14
commit b3b111995e
7 changed files with 227 additions and 292 deletions

View File

@@ -24,6 +24,7 @@ type UploadFileResponse struct {
FileAddressPrefix string `json:"fileAddressPrefix"` // 文件地址前缀
}
// UploadByTask 通过任务上传文件
func UploadByTask(ctx context.Context, data []byte, fileExt string) (oss *UploadFileResponse, err error) {
// multipart
body := &bytes.Buffer{}
@@ -68,12 +69,11 @@ func UploadByTask(ctx context.Context, data []byte, fileExt string) (oss *Upload
// CallbackPayload 回调请求体
type CallbackPayload struct {
TaskId string `json:"task_id"`
State int `json:"state"`
OssFile string `json:"oss_file"`
FileType string `json:"file_type"`
Messages map[string]any `json:"messages"`
ErrorMsg string `json:"error_msg"`
TaskId string `json:"task_id"`
State int `json:"state"`
OssFile string `json:"oss_file"`
FileType string `json:"file_type"`
ErrorMsg string `json:"error_msg"`
}
// TriggerCallback 任务的回调
@@ -85,7 +85,6 @@ func TriggerCallback(ctx context.Context, t *entity.ModelGatewayTask) {
State: t.State,
OssFile: t.ResultFile.OssFile,
FileType: t.ResultFile.FileType,
Messages: t.TextResult,
ErrorMsg: t.ErrorMsg,
}
jsonData, err := json.Marshal(payload)