feat: openapi supoort
This commit is contained in:
@@ -18,6 +18,18 @@ func NewExecutorController(executorService *tasks.ExecutorService) *ExecutorCont
|
||||
return &ExecutorController{executorService: executorService}
|
||||
}
|
||||
|
||||
// ExecuteTask 运行任务
|
||||
// @Summary 运行任务
|
||||
// @Description 立即执行指定的任务
|
||||
// @Tags 任务
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param id path string true "任务ID"
|
||||
// @Param body body object false "执行参数 (envs: 环境变量字典)"
|
||||
// @Success 200 {object} utils.Response{data=vo.ExecutionResultVO}
|
||||
// @Failure 400 {object} utils.Response
|
||||
// @Router /execute/task/{id} [post]
|
||||
func (ec *ExecutorController) ExecuteTask(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
@@ -42,6 +54,17 @@ func (ec *ExecutorController) ExecuteTask(c *gin.Context) {
|
||||
utils.Success(c, vo.ToExecutionResultVO(result))
|
||||
}
|
||||
|
||||
// ExecuteCommand 执行命令
|
||||
// @Summary 执行命令
|
||||
// @Description 临时执行单次命令
|
||||
// @Tags 任务执行
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param body body object true "命令内容 (需包含 command 字段)"
|
||||
// @Success 200 {object} utils.Response{data=vo.ExecutionResultVO}
|
||||
// @Failure 400 {object} utils.Response
|
||||
// @Router /execute/command [post]
|
||||
func (ec *ExecutorController) ExecuteCommand(c *gin.Context) {
|
||||
var req struct {
|
||||
Command string `json:"command" binding:"required"`
|
||||
@@ -56,6 +79,16 @@ func (ec *ExecutorController) ExecuteCommand(c *gin.Context) {
|
||||
utils.Success(c, vo.ToExecutionResultVO(result))
|
||||
}
|
||||
|
||||
// GetLastResults 获取最新执行结果
|
||||
// @Summary 获取最新执行结果
|
||||
// @Description 获取最新任务或命令执行的结果列表
|
||||
// @Tags 任务执行
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param count query int false "数量 (默认 10)"
|
||||
// @Success 200 {object} utils.Response{data=[]vo.ExecutionResultVO}
|
||||
// @Router /execute/results [get]
|
||||
func (ec *ExecutorController) GetLastResults(c *gin.Context) {
|
||||
count := 10
|
||||
if c.Query("count") != "" {
|
||||
|
||||
Reference in New Issue
Block a user