feat(workflow): import files from external storage
This commit is contained in:
@@ -34,6 +34,23 @@ func CreateArchive(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// ImportFiles imports files
|
||||
func ImportFiles(c *gin.Context) {
|
||||
service := ParametersFromContext[*explorer.ImportWorkflowService](c, explorer.CreateImportParamCtx{})
|
||||
resp, err := service.CreateImportTask(c)
|
||||
if err != nil {
|
||||
c.JSON(200, serializer.Err(c, err))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if resp != nil {
|
||||
c.JSON(200, serializer.Response{
|
||||
Data: resp,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// CreateRemoteDownload creates remote download task
|
||||
func CreateRemoteDownload(c *gin.Context) {
|
||||
service := ParametersFromContext[*explorer.DownloadWorkflowService](c, explorer.CreateDownloadParamCtx{})
|
||||
|
||||
@@ -118,13 +118,15 @@ func SlavePing(c *gin.Context) {
|
||||
|
||||
// SlaveList 从机列出文件
|
||||
func SlaveList(c *gin.Context) {
|
||||
var service explorer.SlaveListService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.List(c)
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
service := ParametersFromContext[*explorer.SlaveListService](c, explorer.SlaveListParamCtx{})
|
||||
objects, err := service.List(c)
|
||||
if err != nil {
|
||||
c.JSON(200, serializer.Err(c, err))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, serializer.NewResponseWithGobData(c, objects))
|
||||
}
|
||||
|
||||
// SlaveDownloadTaskCreate creates a download task on slave
|
||||
|
||||
@@ -97,6 +97,11 @@ func initSlaveFileRouter(v4 *gin.RouterGroup) {
|
||||
file.DELETE("",
|
||||
controllers.FromJSON[explorer.SlaveDeleteFileService](explorer.SlaveDeleteFileParamCtx{}),
|
||||
controllers.SlaveDelete)
|
||||
// 列出文件
|
||||
file.GET("list",
|
||||
controllers.FromQuery[explorer.SlaveListService](explorer.SlaveListParamCtx{}),
|
||||
controllers.SlaveList,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,6 +688,12 @@ func initMasterRouter(dep dependency.Dep) *gin.Engine {
|
||||
controllers.FromJSON[explorer.CreateViewerSessionService](explorer.CreateViewerSessionParamCtx{}),
|
||||
controllers.CreateViewerSession,
|
||||
)
|
||||
// Create task to import files
|
||||
wf.POST("import",
|
||||
middleware.IsAdmin(),
|
||||
controllers.FromJSON[explorer.ImportWorkflowService](explorer.CreateImportParamCtx{}),
|
||||
controllers.ImportFiles,
|
||||
)
|
||||
|
||||
// 取得文件外链
|
||||
file.PUT("source",
|
||||
|
||||
Reference in New Issue
Block a user