diff --git a/internal/server/controllers/plugins.go b/internal/server/controllers/plugins.go index 3d4ddc2..3704048 100644 --- a/internal/server/controllers/plugins.go +++ b/internal/server/controllers/plugins.go @@ -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"` diff --git a/internal/server/http_server.go b/internal/server/http_server.go index 0bb46c4..2be06bd 100644 --- a/internal/server/http_server.go +++ b/internal/server/http_server.go @@ -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) diff --git a/internal/service/install_plugin.go b/internal/service/install_plugin.go index b672c16..38d2f0e 100644 --- a/internal/service/install_plugin.go +++ b/internal/service/install_plugin.go @@ -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,