Skip to content

Commit

Permalink
feat: support delete all install tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Nov 25, 2024
1 parent 3f70526 commit dd5325b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/server/controllers/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func DeletePluginInstallationTask(c *gin.Context) {
})
}

func DeleteAllPluginInstallationTasks(c *gin.Context) {
BindRequest(c, func(request struct {
TenantID string `uri:"tenant_id" validate:"required"`
}) {
c.JSON(http.StatusOK, service.DeleteAllPluginInstallationTasks(request.TenantID))
})
}

func DeletePluginInstallationItemFromTask(c *gin.Context) {
BindRequest(c, func(request struct {
TenantID string `uri:"tenant_id" validate:"required"`
Expand Down
1 change: 1 addition & 0 deletions internal/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (app *App) pluginManagementGroup(group *gin.RouterGroup, config *app.Config
group.POST("/install/upgrade", controllers.UpgradePlugin(config))
group.GET("/install/tasks/:id", controllers.FetchPluginInstallationTask)
group.POST("/install/tasks/:id/delete", controllers.DeletePluginInstallationTask)
group.POST("/install/tasks/:id/delete_all", controllers.DeleteAllPluginInstallationTasks)
group.POST("/install/tasks/:id/delete/*identifier", controllers.DeletePluginInstallationItemFromTask)
group.GET("/install/tasks", controllers.FetchPluginInstallationTasks)
group.GET("/fetch/manifest", controllers.FetchPluginManifest)
Expand Down
15 changes: 15 additions & 0 deletions internal/service/install_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,21 @@ func DeletePluginInstallationTask(
return entities.NewSuccessResponse(true)
}

func DeleteAllPluginInstallationTasks(
tenant_id string,
) *entities.Response {
err := db.DeleteByCondition(
models.InstallTask{
TenantID: tenant_id,
},
)
if err != nil {
return exception.InternalServerError(err).ToResponse()
}

return entities.NewSuccessResponse(true)
}

func DeletePluginInstallationItemFromTask(
tenant_id string,
task_id string,
Expand Down

0 comments on commit dd5325b

Please sign in to comment.