feat: add OpenAPI support for task creation
This commit is contained in:
@@ -6,6 +6,55 @@ import (
|
||||
"github.com/engigu/baihu-panel/internal/utils"
|
||||
)
|
||||
|
||||
// TaskCreateReq 任务创建请求
|
||||
type TaskCreateReq struct {
|
||||
Name string `json:"name" binding:"required" example:"测试任务"`
|
||||
Remark string `json:"remark" example:"备注信息"`
|
||||
Command string `json:"command" example:"echo 'Hello World'"`
|
||||
PreCommand string `json:"pre_command" example:"echo 'pre'"`
|
||||
PostCommand string `json:"post_command" example:"echo 'post'"`
|
||||
Tags string `json:"tags" example:"test,dev"`
|
||||
Type string `json:"type" example:"repo"` // 可以是 common, repo 等
|
||||
Config string `json:"config" swaggertype:"string" example:"{\"source_url\":\"https://github.com/abc/repo\",\"branch\":\"main\"}"`
|
||||
Schedule string `json:"schedule" example:"0 0 * * *"`
|
||||
Timeout int `json:"timeout" example:"3600"`
|
||||
WorkDir string `json:"work_dir" example:"/tmp"`
|
||||
CleanConfig string `json:"clean_config" example:"true"`
|
||||
Envs string `json:"envs" example:"{\"ENV_VAR\":\"value\"}"`
|
||||
Languages models.TaskLanguages `json:"languages"`
|
||||
AgentID *string `json:"agent_id" example:"agent-1"`
|
||||
TriggerType string `json:"trigger_type" example:"cron"`
|
||||
RetryCount int `json:"retry_count" example:"3"`
|
||||
RetryInterval int `json:"retry_interval" example:"60"`
|
||||
RandomRange int `json:"random_range" example:"10"`
|
||||
PinType string `json:"pin_type" example:"time"`
|
||||
}
|
||||
|
||||
// TaskUpdateReq 任务更新请求
|
||||
type TaskUpdateReq struct {
|
||||
Name string `json:"name" example:"测试任务"`
|
||||
Remark string `json:"remark" example:"备注信息"`
|
||||
Command string `json:"command" example:"echo 'Hello World'"`
|
||||
PreCommand string `json:"pre_command" example:"echo 'pre'"`
|
||||
PostCommand string `json:"post_command" example:"echo 'post'"`
|
||||
Tags string `json:"tags" example:"test,dev"`
|
||||
Type string `json:"type" example:"repo"`
|
||||
Config string `json:"config" swaggertype:"string" example:"{\"source_url\":\"https://github.com/abc/repo\",\"branch\":\"main\"}"`
|
||||
Schedule string `json:"schedule" example:"0 0 * * *"`
|
||||
Timeout int `json:"timeout" example:"3600"`
|
||||
WorkDir string `json:"work_dir" example:"/tmp"`
|
||||
CleanConfig string `json:"clean_config" example:"true"`
|
||||
Envs string `json:"envs" example:"{\"ENV_VAR\":\"value\"}"`
|
||||
Enabled bool `json:"enabled" example:"true"`
|
||||
Languages models.TaskLanguages `json:"languages"`
|
||||
AgentID *string `json:"agent_id" example:"agent-1"`
|
||||
TriggerType string `json:"trigger_type" example:"cron"`
|
||||
RetryCount int `json:"retry_count" example:"3"`
|
||||
RetryInterval int `json:"retry_interval" example:"60"`
|
||||
RandomRange int `json:"random_range" example:"10"`
|
||||
PinType string `json:"pin_type" example:"time"`
|
||||
}
|
||||
|
||||
// TaskVO 任务视图对象
|
||||
type TaskVO struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user