feat: add task running status #88

This commit is contained in:
duorameng
2026-04-30 15:44:45 +08:00
parent 03cdb38ef6
commit 404a1a4bfe
5 changed files with 76 additions and 35 deletions
+7
View File
@@ -99,6 +99,13 @@ type Task struct {
UpdatedAt LocalTime `json:"updated_at"`
}
func (t *Task) IsRunning() bool {
if string(t.RunningGo) == "" || string(t.RunningGo) == "[]" {
return false
}
return true
}
func (Task) TableName() string {
return constant.TablePrefix + "tasks"
}
+7
View File
@@ -32,6 +32,7 @@ type TaskVO struct {
NextRun *models.LocalTime `json:"next_run"`
CreatedAt models.LocalTime `json:"created_at"`
UpdatedAt models.LocalTime `json:"updated_at"`
RunningStatus string `json:"running_status"`
}
// ToTaskVO 将 Task 模型转换为 TaskVO
@@ -64,6 +65,12 @@ func ToTaskVO(task *models.Task) *TaskVO {
NextRun: task.NextRun,
CreatedAt: task.CreatedAt,
UpdatedAt: task.UpdatedAt,
RunningStatus: func() string {
if task.IsRunning() {
return "running"
}
return "idle"
}(),
}
}