package model import ( "encoding/json" "time" ) // TaskPlan 任务计划 type TaskPlan struct { ID string `gorm:"primaryKey;column:id;type:VARCHAR(128);not null" json:"id"` UserID int64 `gorm:"column:user_id;type:BIGINT;not null" json:"userId"` Name string `gorm:"column:name;type:VARCHAR(128);not null" json:"name"` DockID string `gorm:"column:dock_id;type:VARCHAR(64);not null" json:"dockId"` RouteID int64 `gorm:"column:route_id;type:BIGINT" json:"routeId"` ScheduleType string `gorm:"column:schedule_type;type:VARCHAR(16);default:once" json:"scheduleType"` // once / cron ScheduleCron string `gorm:"column:schedule_cron;type:VARCHAR(32)" json:"scheduleCron"` VideoPolicy string `gorm:"column:video_policy;type:VARCHAR(16);default:raw" json:"videoPolicy"` Status string `gorm:"column:status;type:VARCHAR(16);default:draft" json:"status"` CreatedBy int64 `gorm:"column:created_by;type:BIGINT" json:"createdBy"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` } func (TaskPlan) TableName() string { return "task_plan" } // TaskExecution 任务执行记录 type TaskExecution struct { ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"` TaskID string `gorm:"column:task_id;type:VARCHAR(128)" json:"taskId"` CommandID string `gorm:"column:command_id;type:VARCHAR(64)" json:"commandId"` DockID string `gorm:"column:dock_id;type:VARCHAR(64);not null" json:"dockId"` DroneSN string `gorm:"column:drone_sn;type:VARCHAR(32)" json:"droneSn"` StartTime *time.Time `gorm:"column:start_time" json:"startTime"` EndTime *time.Time `gorm:"column:end_time" json:"endTime"` Status string `gorm:"column:status;type:VARCHAR(16);default:pending" json:"status"` ResultCode string `gorm:"column:result_code;type:VARCHAR(64)" json:"resultCode"` TrajectoryJSON json.RawMessage `gorm:"column:trajectory_json;type:JSON" json:"trajectoryJson"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` } func (TaskExecution) TableName() string { return "task_execution" } // WorkflowState 工作流状态(任务/一键流程执行步骤跟踪) type WorkflowState struct { ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"` DockID string `gorm:"column:dock_id;type:VARCHAR(64);not null" json:"dockId"` CommandID string `gorm:"column:command_id;type:VARCHAR(64)" json:"commandId"` Type string `gorm:"column:type;type:VARCHAR(64)" json:"type"` TaskID string `gorm:"column:task_id;type:VARCHAR(128)" json:"taskId"` MissionID string `gorm:"column:mission_id;type:VARCHAR(128)" json:"missionId"` State string `gorm:"column:state;type:VARCHAR(16);not null" json:"state"` // idle / running / succeeded / failed / cancelled Step string `gorm:"column:step;type:VARCHAR(64);not null" json:"step"` ResultCode string `gorm:"column:result_code;type:VARCHAR(64)" json:"resultCode"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` } func (WorkflowState) TableName() string { return "workflow_state" }