diff --git a/.swaggo b/.swaggo deleted file mode 100644 index e4e3b322..00000000 --- a/.swaggo +++ /dev/null @@ -1 +0,0 @@ -replace carbon.DateTime string \ No newline at end of file diff --git a/app/http/controllers/plugin_controller.go b/app/http/controllers/plugin_controller.go index 90d6ca9d..72a03d39 100644 --- a/app/http/controllers/plugin_controller.go +++ b/app/http/controllers/plugin_controller.go @@ -21,7 +21,14 @@ func NewPluginController() *PluginController { } } -// List 列出所有插件 +// List +// +// @Summary 插件列表 +// @Tags 插件 +// @Produce json +// @Security BearerToken +// @Success 200 {object} controllers.SuccessResponse +// @Router /panel/plugin/list [get] func (r *PluginController) List(ctx http.Context) http.Response { plugins := r.plugin.All() installedPlugins, err := r.plugin.AllInstalled() @@ -89,7 +96,15 @@ func (r *PluginController) List(ctx http.Context) http.Response { }) } -// Install 安装插件 +// Install +// +// @Summary 安装插件 +// @Tags 插件 +// @Produce json +// @Security BearerToken +// @Param slug query string true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /panel/plugin/install [post] func (r *PluginController) Install(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") @@ -100,7 +115,15 @@ func (r *PluginController) Install(ctx http.Context) http.Response { return Success(ctx, "任务已提交") } -// Uninstall 卸载插件 +// Uninstall +// +// @Summary 卸载插件 +// @Tags 插件 +// @Produce json +// @Security BearerToken +// @Param slug query string true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /panel/plugin/uninstall [post] func (r *PluginController) Uninstall(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") @@ -111,7 +134,15 @@ func (r *PluginController) Uninstall(ctx http.Context) http.Response { return Success(ctx, "任务已提交") } -// Update 更新插件 +// Update +// +// @Summary 更新插件 +// @Tags 插件 +// @Produce json +// @Security BearerToken +// @Param slug query string true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /panel/plugin/update [post] func (r *PluginController) Update(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") @@ -122,7 +153,16 @@ func (r *PluginController) Update(ctx http.Context) http.Response { return Success(ctx, "任务已提交") } -// UpdateShow 更新插件首页显示状态 +// UpdateShow +// +// @Summary 更新插件首页显示状态 +// @Tags 插件 +// @Produce json +// @Security BearerToken +// @Param slug query string true "request" +// @Param show query bool true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /panel/plugin/updateShow [post] func (r *PluginController) UpdateShow(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") show := ctx.Request().InputBool("show") @@ -150,3 +190,23 @@ func (r *PluginController) UpdateShow(ctx http.Context) http.Response { return Success(ctx, "操作成功") } + +// IsInstalled +// +// @Summary 检查插件是否已安装 +// @Tags 插件 +// @Produce json +// @Security BearerToken +// @Param slug query string true "request" +// @Success 200 {object} controllers.SuccessResponse +// @Router /panel/plugin/isInstalled [get] +func (r *PluginController) IsInstalled(ctx http.Context) http.Response { + slug := ctx.Request().Input("slug") + + plugin := r.plugin.GetInstalledBySlug(slug) + if plugin.Slug != slug { + return Success(ctx, false) + } + + return Success(ctx, true) +} diff --git a/app/http/middleware/must_install.go b/app/http/middleware/must_install.go deleted file mode 100644 index cc6b94cd..00000000 --- a/app/http/middleware/must_install.go +++ /dev/null @@ -1,93 +0,0 @@ -package middleware - -import ( - "strings" - - "github.com/goravel/framework/contracts/http" - "github.com/goravel/framework/contracts/translation" - "github.com/goravel/framework/facades" - - "github.com/TheTNB/panel/internal/services" -) - -// MustInstall 确保已安装插件 -func MustInstall() http.Middleware { - return func(ctx http.Context) { - path := ctx.Request().Path() - translate := facades.Lang(ctx) - var slug string - if strings.HasPrefix(path, "/api/panel/website") { - slug = "openresty" - } else if strings.HasPrefix(path, "/api/panel/container") { - slug = "podman" - } else { - pathArr := strings.Split(path, "/") - if len(pathArr) < 4 { - ctx.Request().AbortWithStatusJson(http.StatusForbidden, http.Json{ - "message": translate.Get("errors.plugin.notExist"), - }) - return - } - slug = pathArr[3] - } - - plugin := services.NewPluginImpl().GetBySlug(slug) - installedPlugin := services.NewPluginImpl().GetInstalledBySlug(slug) - installedPlugins, err := services.NewPluginImpl().AllInstalled() - if err != nil { - ctx.Request().AbortWithStatusJson(http.StatusInternalServerError, http.Json{ - "message": translate.Get("errors.internal"), - }) - return - } - - if installedPlugin.Slug != plugin.Slug { - ctx.Request().AbortWithStatusJson(http.StatusForbidden, http.Json{ - "message": translate.Get("errors.plugin.notInstalled", translation.Option{ - Replace: map[string]string{ - "slug": slug, - }, - }), - }) - return - } - - pluginsMap := make(map[string]bool) - - for _, p := range installedPlugins { - pluginsMap[p.Slug] = true - } - - for _, require := range plugin.Requires { - _, requireFound := pluginsMap[require] - if !requireFound { - ctx.Request().AbortWithStatusJson(http.StatusForbidden, http.Json{ - "message": translate.Get("errors.plugin.dependent", translation.Option{ - Replace: map[string]string{ - "slug": slug, - "dependency": require, - }, - }), - }) - return - } - } - - for _, exclude := range plugin.Excludes { - _, excludeFound := pluginsMap[exclude] - if excludeFound { - ctx.Request().AbortWithStatusJson(http.StatusForbidden, http.Json{ - "message": translate.Get("errors.plugin.incompatible", translation.Option{ - Replace: map[string]string{ - "slug": slug, - "exclude": exclude, - }, - }), - }) - return - } - } - - ctx.Request().Next() - } -} diff --git a/docs/docs.go b/docs/docs.go index 5c6dbaa3..9ae94e3e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2634,6 +2634,202 @@ const docTemplate = `{ } } }, + "/panel/plugin/install": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "安装插件", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/isInstalled": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "检查插件是否已安装", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/list": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "插件列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/uninstall": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "卸载插件", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/update": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "更新插件", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/updateShow": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "更新插件首页显示状态", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + }, + { + "type": "boolean", + "description": "request", + "name": "show", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, "/panel/setting/list": { "get": { "security": [ @@ -3746,236 +3942,6 @@ const docTemplate = `{ } } }, - "/plugins/frp/disable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "禁用 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "禁用服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/enable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启用 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "启用服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/isEnabled": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取是否启用 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "是否启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "重启服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "启动服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Frp 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "停止服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/plugins/gitea/config": { "get": { "security": [ @@ -4035,256 +4001,6 @@ const docTemplate = `{ } } }, - "/plugins/gitea/disable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "禁用 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "禁用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/enable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启用 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/isEnabled": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取是否启用 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "是否启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "重启服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "启动服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Gitea 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "停止服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/disable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "禁用 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "禁用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/enable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启用 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/isEnabled": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取是否启用 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "是否启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/plugins/podman/registryConfig": { "get": { "security": [ @@ -4344,106 +4060,6 @@ const docTemplate = `{ } } }, - "/plugins/podman/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "重启服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "启动服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Podman 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "停止服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/plugins/podman/storageConfig": { "get": { "security": [ @@ -4708,106 +4324,6 @@ const docTemplate = `{ } } }, - "/plugins/rsync/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Rsync 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "重启服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/rsync/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Rsync 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "启动服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/rsync/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Rsync 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/rsync/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Rsync 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "停止服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/swagger": { "get": { "description": "Swagger UI", @@ -4968,6 +4484,12 @@ const docTemplate = `{ } } }, + "github_com_goravel_framework_support_carbon.DateTime": { + "type": "object", + "properties": { + "error": {} + } + }, "models.Cert": { "type": "object", "properties": { @@ -4984,7 +4506,7 @@ const docTemplate = `{ "type": "string" }, "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "dns": { "$ref": "#/definitions/models.CertDNS" @@ -5011,7 +4533,7 @@ const docTemplate = `{ "type": "string" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "user": { "$ref": "#/definitions/models.CertUser" @@ -5033,7 +4555,7 @@ const docTemplate = `{ "type": "object", "properties": { "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "dns_param": { "$ref": "#/definitions/acme.DNSParam" @@ -5050,7 +4572,7 @@ const docTemplate = `{ "type": "string" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" } } }, @@ -5062,7 +4584,7 @@ const docTemplate = `{ "type": "string" }, "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "email": { "type": "string" @@ -5083,7 +4605,7 @@ const docTemplate = `{ "type": "string" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" } } }, @@ -5094,7 +4616,7 @@ const docTemplate = `{ "$ref": "#/definitions/models.Cert" }, "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "id": { "type": "integer" @@ -5118,7 +4640,7 @@ const docTemplate = `{ "type": "boolean" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" } } }, @@ -5622,14 +5144,6 @@ const docTemplate = `{ } } }, - "requests.Service": { - "type": "object", - "properties": { - "service": { - "type": "string" - } - } - }, "requests.UnArchive": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 2479241f..e6024402 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2627,6 +2627,202 @@ } } }, + "/panel/plugin/install": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "安装插件", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/isInstalled": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "检查插件是否已安装", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/list": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "插件列表", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/uninstall": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "卸载插件", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/update": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "更新插件", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/panel/plugin/updateShow": { + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "produces": [ + "application/json" + ], + "tags": [ + "插件" + ], + "summary": "更新插件首页显示状态", + "parameters": [ + { + "type": "string", + "description": "request", + "name": "slug", + "in": "query", + "required": true + }, + { + "type": "boolean", + "description": "request", + "name": "show", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, "/panel/setting/list": { "get": { "security": [ @@ -3739,236 +3935,6 @@ } } }, - "/plugins/frp/disable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "禁用 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "禁用服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/enable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启用 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "启用服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/isEnabled": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取是否启用 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "是否启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "重启服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "启动服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Frp 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/frp/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Frp 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Frp" - ], - "summary": "停止服务", - "parameters": [ - { - "description": "request", - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/requests.Service" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/plugins/gitea/config": { "get": { "security": [ @@ -4028,256 +3994,6 @@ } } }, - "/plugins/gitea/disable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "禁用 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "禁用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/enable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启用 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/isEnabled": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取是否启用 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "是否启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "重启服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "启动服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Gitea 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/gitea/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Gitea 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Gitea" - ], - "summary": "停止服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/disable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "禁用 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "禁用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/enable": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启用 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/isEnabled": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取是否启用 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "是否启用服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/plugins/podman/registryConfig": { "get": { "security": [ @@ -4337,106 +4053,6 @@ } } }, - "/plugins/podman/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "重启服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "启动服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Podman 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/podman/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Podman 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Podman" - ], - "summary": "停止服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/plugins/podman/storageConfig": { "get": { "security": [ @@ -4701,106 +4317,6 @@ } } }, - "/plugins/rsync/restart": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "重启 Rsync 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "重启服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/rsync/start": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "启动 Rsync 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "启动服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/rsync/status": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取 Rsync 服务状态", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "服务状态", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, - "/plugins/rsync/stop": { - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "停止 Rsync 服务", - "produces": [ - "application/json" - ], - "tags": [ - "插件-Rsync" - ], - "summary": "停止服务", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controllers.SuccessResponse" - } - } - } - } - }, "/swagger": { "get": { "description": "Swagger UI", @@ -4961,6 +4477,12 @@ } } }, + "github_com_goravel_framework_support_carbon.DateTime": { + "type": "object", + "properties": { + "error": {} + } + }, "models.Cert": { "type": "object", "properties": { @@ -4977,7 +4499,7 @@ "type": "string" }, "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "dns": { "$ref": "#/definitions/models.CertDNS" @@ -5004,7 +4526,7 @@ "type": "string" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "user": { "$ref": "#/definitions/models.CertUser" @@ -5026,7 +4548,7 @@ "type": "object", "properties": { "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "dns_param": { "$ref": "#/definitions/acme.DNSParam" @@ -5043,7 +4565,7 @@ "type": "string" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" } } }, @@ -5055,7 +4577,7 @@ "type": "string" }, "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "email": { "type": "string" @@ -5076,7 +4598,7 @@ "type": "string" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" } } }, @@ -5087,7 +4609,7 @@ "$ref": "#/definitions/models.Cert" }, "created_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" }, "id": { "type": "integer" @@ -5111,7 +4633,7 @@ "type": "boolean" }, "updated_at": { - "type": "string" + "$ref": "#/definitions/github_com_goravel_framework_support_carbon.DateTime" } } }, @@ -5615,14 +5137,6 @@ } } }, - "requests.Service": { - "type": "object", - "properties": { - "service": { - "type": "string" - } - } - }, "requests.UnArchive": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 4eca7b6a..0689fe55 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -91,6 +91,10 @@ definitions: website_path: type: string type: object + github_com_goravel_framework_support_carbon.DateTime: + properties: + error: {} + type: object models.Cert: properties: auto_renew: @@ -103,7 +107,7 @@ definitions: description: 证书 URL (续签时使用) type: string created_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' dns: $ref: '#/definitions/models.CertDNS' dns_id: @@ -122,7 +126,7 @@ definitions: description: 证书类型 (P256, P384, 2048, 4096) type: string updated_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' user: $ref: '#/definitions/models.CertUser' user_id: @@ -137,7 +141,7 @@ definitions: models.CertDNS: properties: created_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' dns_param: $ref: '#/definitions/acme.DNSParam' id: @@ -149,7 +153,7 @@ definitions: description: DNS 提供商 (dnspod, aliyun, cloudflare) type: string updated_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' type: object models.CertUser: properties: @@ -157,7 +161,7 @@ definitions: description: CA 提供商 (letsencrypt, zerossl, sslcom, google, buypass) type: string created_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' email: type: string hmac_encoded: @@ -171,14 +175,14 @@ definitions: private_key: type: string updated_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' type: object models.Website: properties: cert: $ref: '#/definitions/models.Cert' created_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' id: type: integer name: @@ -194,7 +198,7 @@ definitions: status: type: boolean updated_at: - type: string + $ref: '#/definitions/github_com_goravel_framework_support_carbon.DateTime' type: object requests.Add: properties: @@ -521,11 +525,6 @@ definitions: path: type: string type: object - requests.Service: - properties: - service: - type: string - type: object requests.UnArchive: properties: file: @@ -2266,6 +2265,125 @@ paths: summary: 上传文件 tags: - 文件管理 + /panel/plugin/install: + post: + parameters: + - description: request + in: query + name: slug + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 安装插件 + tags: + - 插件 + /panel/plugin/isInstalled: + get: + parameters: + - description: request + in: query + name: slug + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 检查插件是否已安装 + tags: + - 插件 + /panel/plugin/list: + get: + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 插件列表 + tags: + - 插件 + /panel/plugin/uninstall: + post: + parameters: + - description: request + in: query + name: slug + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 卸载插件 + tags: + - 插件 + /panel/plugin/update: + post: + parameters: + - description: request + in: query + name: slug + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 更新插件 + tags: + - 插件 + /panel/plugin/updateShow: + post: + parameters: + - description: request + in: query + name: slug + required: true + type: string + - description: request + in: query + name: show + required: true + type: boolean + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 更新插件首页显示状态 + tags: + - 插件 /panel/setting/list: get: description: 获取面板设置列表 @@ -2942,146 +3060,6 @@ paths: summary: 更新配置 tags: - 插件-Frp - /plugins/frp/disable: - post: - description: 禁用 Frp 服务 - parameters: - - description: request - in: body - name: data - required: true - schema: - $ref: '#/definitions/requests.Service' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 禁用服务 - tags: - - 插件-Frp - /plugins/frp/enable: - post: - description: 启用 Frp 服务 - parameters: - - description: request - in: body - name: data - required: true - schema: - $ref: '#/definitions/requests.Service' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启用服务 - tags: - - 插件-Frp - /plugins/frp/isEnabled: - get: - description: 获取是否启用 Frp 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 是否启用服务 - tags: - - 插件-Frp - /plugins/frp/restart: - post: - description: 重启 Frp 服务 - parameters: - - description: request - in: body - name: data - required: true - schema: - $ref: '#/definitions/requests.Service' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 重启服务 - tags: - - 插件-Frp - /plugins/frp/start: - post: - description: 启动 Frp 服务 - parameters: - - description: request - in: body - name: data - required: true - schema: - $ref: '#/definitions/requests.Service' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启动服务 - tags: - - 插件-Frp - /plugins/frp/status: - get: - description: 获取 Frp 服务状态 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 服务状态 - tags: - - 插件-Frp - /plugins/frp/stop: - post: - description: 停止 Frp 服务 - parameters: - - description: request - in: body - name: data - required: true - schema: - $ref: '#/definitions/requests.Service' - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 停止服务 - tags: - - 插件-Frp /plugins/gitea/config: get: description: 获取 Gitea 配置 @@ -3118,156 +3096,6 @@ paths: summary: 更新配置 tags: - 插件-Gitea - /plugins/gitea/disable: - post: - description: 禁用 Gitea 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 禁用服务 - tags: - - 插件-Gitea - /plugins/gitea/enable: - post: - description: 启用 Gitea 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启用服务 - tags: - - 插件-Gitea - /plugins/gitea/isEnabled: - get: - description: 获取是否启用 Gitea 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 是否启用服务 - tags: - - 插件-Gitea - /plugins/gitea/restart: - post: - description: 重启 Gitea 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 重启服务 - tags: - - 插件-Gitea - /plugins/gitea/start: - post: - description: 启动 Gitea 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启动服务 - tags: - - 插件-Gitea - /plugins/gitea/status: - get: - description: 获取 Gitea 服务状态 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 服务状态 - tags: - - 插件-Gitea - /plugins/gitea/stop: - post: - description: 停止 Gitea 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 停止服务 - tags: - - 插件-Gitea - /plugins/podman/disable: - post: - description: 禁用 Podman 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 禁用服务 - tags: - - 插件-Podman - /plugins/podman/enable: - post: - description: 启用 Podman 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启用服务 - tags: - - 插件-Podman - /plugins/podman/isEnabled: - get: - description: 获取是否启用 Podman 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 是否启用服务 - tags: - - 插件-Podman /plugins/podman/registryConfig: get: description: 获取 Podman 注册表配置 @@ -3304,66 +3132,6 @@ paths: summary: 更新注册表配置 tags: - 插件-Podman - /plugins/podman/restart: - post: - description: 重启 Podman 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 重启服务 - tags: - - 插件-Podman - /plugins/podman/start: - post: - description: 启动 Podman 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启动服务 - tags: - - 插件-Podman - /plugins/podman/status: - get: - description: 获取 Podman 服务状态 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 服务状态 - tags: - - 插件-Podman - /plugins/podman/stop: - post: - description: 停止 Podman 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 停止服务 - tags: - - 插件-Podman /plugins/podman/storageConfig: get: description: 获取 Podman 存储配置 @@ -3526,66 +3294,6 @@ paths: summary: 更新模块 tags: - 插件-Rsync - /plugins/rsync/restart: - post: - description: 重启 Rsync 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 重启服务 - tags: - - 插件-Rsync - /plugins/rsync/start: - post: - description: 启动 Rsync 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 启动服务 - tags: - - 插件-Rsync - /plugins/rsync/status: - get: - description: 获取 Rsync 服务状态 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 服务状态 - tags: - - 插件-Rsync - /plugins/rsync/stop: - post: - description: 停止 Rsync 服务 - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controllers.SuccessResponse' - security: - - BearerToken: [] - summary: 停止服务 - tags: - - 插件-Rsync /swagger: get: description: Swagger UI diff --git a/internal/services/plugin.go b/internal/services/plugin.go index 234f967a..2efc6c26 100644 --- a/internal/services/plugin.go +++ b/internal/services/plugin.go @@ -76,10 +76,7 @@ func (r *PluginImpl) GetBySlug(slug string) types.Plugin { // GetInstalledBySlug 根据 slug 获取已安装的插件 func (r *PluginImpl) GetInstalledBySlug(slug string) models.Plugin { var plugin models.Plugin - if err := facades.Orm().Query().Where("slug", slug).Get(&plugin); err != nil { - return plugin - } - + _ = facades.Orm().Query().Where("slug", slug).Get(&plugin) return plugin } diff --git a/lang/en.json b/lang/en.json index 70a65eac..7e979017 100644 --- a/lang/en.json +++ b/lang/en.json @@ -186,13 +186,7 @@ } }, "errors": { - "internal": "internal system error", - "plugin": { - "notExist": "plugin does not exist", - "notInstalled": "plugin :slug is not installed", - "dependent": "plugin :slug requires dependency :dependency", - "incompatible": "plugin :slug is incompatible with :exclude plugin" - } + "internal": "internal system error" }, "messages": { "mistake": "mistake" diff --git a/lang/zh_CN.json b/lang/zh_CN.json index 0d1d32b6..16e17d2b 100644 --- a/lang/zh_CN.json +++ b/lang/zh_CN.json @@ -186,13 +186,7 @@ } }, "errors": { - "internal": "系统内部错误", - "plugin": { - "notExist": "插件不存在", - "notInstalled": "插件 :slug 未安装", - "dependent": "插件 :slug 需要依赖 :dependency 插件", - "incompatible": "插件 :slug 不兼容 :exclude 插件" - } + "internal": "系统内部错误" }, "messages": { "mistake": "错误" diff --git a/routes/api.go b/routes/api.go index 035a70be..26bb6366 100644 --- a/routes/api.go +++ b/routes/api.go @@ -35,7 +35,7 @@ func Api() { r.Get("log", taskController.Log) r.Post("delete", taskController.Delete) }) - r.Prefix("website").Middleware(middleware.Jwt(), middleware.MustInstall()).Group(func(r route.Router) { + r.Prefix("website").Middleware(middleware.Jwt()).Group(func(r route.Router) { websiteController := controllers.NewWebsiteController() r.Get("defaultConfig", websiteController.GetDefaultConfig) r.Post("defaultConfig", websiteController.SaveDefaultConfig) @@ -43,7 +43,7 @@ func Api() { r.Put("uploadBackup", websiteController.UploadBackup) r.Delete("deleteBackup", websiteController.DeleteBackup) }) - r.Prefix("websites").Middleware(middleware.Jwt(), middleware.MustInstall()).Group(func(r route.Router) { + r.Prefix("websites").Middleware(middleware.Jwt()).Group(func(r route.Router) { websiteController := controllers.NewWebsiteController() r.Get("/", websiteController.List) r.Post("/", websiteController.Add) @@ -89,6 +89,7 @@ func Api() { r.Post("uninstall", pluginController.Uninstall) r.Post("update", pluginController.Update) r.Post("updateShow", pluginController.UpdateShow) + r.Get("isInstalled", pluginController.IsInstalled) }) r.Prefix("cron").Middleware(middleware.Jwt()).Group(func(r route.Router) { cronController := controllers.NewCronController() @@ -114,7 +115,7 @@ func Api() { r.Get("pingStatus", safeController.GetPingStatus) r.Post("pingStatus", safeController.SetPingStatus) }) - r.Prefix("container").Middleware(middleware.Jwt(), middleware.MustInstall()).Group(func(r route.Router) { + r.Prefix("container").Middleware(middleware.Jwt()).Group(func(r route.Router) { containerController := controllers.NewContainerController() r.Get("list", containerController.ContainerList) r.Get("search", containerController.ContainerSearch) diff --git a/routes/plugin.go b/routes/plugin.go index a5b20506..9e1306bc 100644 --- a/routes/plugin.go +++ b/routes/plugin.go @@ -10,7 +10,7 @@ import ( // Plugin 加载插件路由 func Plugin() { - facades.Route().Prefix("api/plugins").Middleware(middleware.Jwt(), middleware.MustInstall()).Group(func(r route.Router) { + facades.Route().Prefix("api/plugins").Middleware(middleware.Jwt()).Group(func(r route.Router) { r.Prefix("openresty").Group(func(route route.Router) { openRestyController := plugins.NewOpenrestyController() route.Get("load", openRestyController.Load)