fix: 修复新建任务后任务列表返回为空的问题
- 在 Task 模型中添加 ExternalID 字段用于关联内存中的 taskID - 修改 Generate 函数,将任务记录同时存入内存和数据库 - 添加 saveTaskToDB 和 updateTaskInDB 函数处理任务持久化 - 同步更新任务状态到数据库,确保 GetProjectTasks 能正确查询 - 处理 default 工程的特殊情况(跳过数据库存储)
This commit is contained in:
@@ -4,15 +4,16 @@ import "time"
|
||||
|
||||
// Task 任务数据模型,对应数据库表。
|
||||
type Task struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
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"`
|
||||
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"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user