3081066d35
- 新建 Asset 模型并添加自动迁移 - 移除 taskStore 内存中的任务缓存 - 新任务直接写入数据库 Task 表 - 任务状态更新同步写入数据库 - 素材上传结果保存到 Asset 表 - GetTask/GetAssets 从数据库查询 - 添加 Metadata 字段到 Task 模型存储完整元数据
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// Task 任务数据模型,对应数据库表。
|
|
type Task struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
ExternalID string `gorm:"size:100;index" json:"externalId,omitempty"` // 外部任务ID,关联taskID
|
|
ProjectID uint `gorm:"index" json:"-"`
|
|
Prompt string `gorm:"type:text" json:"prompt"`
|
|
AssetType string `gorm:"size:50" json:"assetType"`
|
|
Status string `gorm:"size:20;default:'pending'" json:"status"`
|
|
Stage string `gorm:"size:50" json:"stage,omitempty"`
|
|
Progress int `gorm:"default:0" json:"progress"`
|
|
RetryCount int `gorm:"default:0" json:"retryCount"`
|
|
Error string `gorm:"type:text" json:"error,omitempty"`
|
|
Metadata string `gorm:"type:text" json:"-"` // 元数据(JSON格式)
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
|
}
|
|
|
|
// TaskResponse 任务响应。
|
|
type TaskResponse struct {
|
|
ID string `json:"id"`
|
|
ProjectID string `json:"projectId"`
|
|
Prompt string `json:"prompt"`
|
|
AssetType string `json:"assetType"`
|
|
Status string `json:"status"`
|
|
Stage string `json:"stage,omitempty"`
|
|
Progress int `json:"progress"`
|
|
RetryCount int `json:"retryCount"`
|
|
Error string `json:"error,omitempty"`
|
|
CreatedAt string `json:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt,omitempty"`
|
|
}
|