|
|
|
@@ -0,0 +1,30 @@ |
|
|
|
package handler |
|
|
|
|
|
|
|
import ( |
|
|
|
"PCM/adaptor/slurm/slurmCore/api/internal/logic" |
|
|
|
"PCM/adaptor/slurm/slurmCore/api/internal/svc" |
|
|
|
"PCM/adaptor/slurm/slurmCore/api/internal/types" |
|
|
|
"PCM/common/tool" |
|
|
|
"github.com/zeromicro/go-zero/rest/httpx" |
|
|
|
"net/http" |
|
|
|
) |
|
|
|
|
|
|
|
func scheduleTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
|
|
|
return func(w http.ResponseWriter, r *http.Request) { |
|
|
|
var req types.ScheduleTaskReq |
|
|
|
if err := httpx.Parse(r, &req); err != nil { |
|
|
|
httpx.ErrorCtx(r.Context(), w, err) |
|
|
|
return |
|
|
|
} |
|
|
|
l := logic.NewScheduleTaskLogic(r.Context(), svcCtx) |
|
|
|
// 解析yaml文件 |
|
|
|
_, fileHeader, err := r.FormFile("file") |
|
|
|
err = tool.Yaml2struct(fileHeader, &req) |
|
|
|
resp, err := l.ScheduleTask(&req) |
|
|
|
if err != nil { |
|
|
|
httpx.ErrorCtx(r.Context(), w, err) |
|
|
|
} else { |
|
|
|
httpx.OkJsonCtx(r.Context(), w, resp) |
|
|
|
} |
|
|
|
} |
|
|
|
} |