diff --git a/app/http/controllers/plugin_controller.go b/app/http/controllers/plugin_controller.go index 9d198cd4..90d6ca9d 100644 --- a/app/http/controllers/plugin_controller.go +++ b/app/http/controllers/plugin_controller.go @@ -94,7 +94,7 @@ func (r *PluginController) Install(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") if err := r.plugin.Install(slug); err != nil { - return ErrorSystem(ctx) + return Error(ctx, http.StatusInternalServerError, err.Error()) } return Success(ctx, "任务已提交") @@ -105,7 +105,7 @@ func (r *PluginController) Uninstall(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") if err := r.plugin.Uninstall(slug); err != nil { - return ErrorSystem(ctx) + return Error(ctx, http.StatusInternalServerError, err.Error()) } return Success(ctx, "任务已提交") @@ -116,7 +116,7 @@ func (r *PluginController) Update(ctx http.Context) http.Response { slug := ctx.Request().Input("slug") if err := r.plugin.Update(slug); err != nil { - return ErrorSystem(ctx) + return Error(ctx, http.StatusInternalServerError, err.Error()) } return Success(ctx, "任务已提交") diff --git a/app/http/controllers/plugins/gitea_controller.go b/app/http/controllers/plugins/gitea_controller.go index b21e3aaf..e5ccd62c 100644 --- a/app/http/controllers/plugins/gitea_controller.go +++ b/app/http/controllers/plugins/gitea_controller.go @@ -58,7 +58,7 @@ func (r *GiteaController) IsEnabled(ctx http.Context) http.Response { // @Tags 插件-Gitea // @Produce json // @Security BearerToken -// @Success 200 {object} controllers.SuccessResponse +// @Success 200 {object} controllers.SuccessResponse // @Router /plugins/gitea/enable [post] func (r *GiteaController) Enable(ctx http.Context) http.Response { if err := tools.ServiceEnable("gitea"); err != nil { @@ -75,7 +75,7 @@ func (r *GiteaController) Enable(ctx http.Context) http.Response { // @Tags 插件-Gitea // @Produce json // @Security BearerToken -// @Success 200 {object} controllers.SuccessResponse +// @Success 200 {object} controllers.SuccessResponse // @Router /plugins/gitea/disable [post] func (r *GiteaController) Disable(ctx http.Context) http.Response { if err := tools.ServiceDisable("gitea"); err != nil { @@ -92,7 +92,7 @@ func (r *GiteaController) Disable(ctx http.Context) http.Response { // @Tags 插件-Gitea // @Produce json // @Security BearerToken -// @Success 200 {object} controllers.SuccessResponse +// @Success 200 {object} controllers.SuccessResponse // @Router /plugins/gitea/restart [post] func (r *GiteaController) Restart(ctx http.Context) http.Response { if err := tools.ServiceRestart("gitea"); err != nil { @@ -109,7 +109,7 @@ func (r *GiteaController) Restart(ctx http.Context) http.Response { // @Tags 插件-Gitea // @Produce json // @Security BearerToken -// @Success 200 {object} controllers.SuccessResponse +// @Success 200 {object} controllers.SuccessResponse // @Router /plugins/gitea/start [post] func (r *GiteaController) Start(ctx http.Context) http.Response { if err := tools.ServiceStart("gitea"); err != nil { @@ -131,7 +131,7 @@ func (r *GiteaController) Start(ctx http.Context) http.Response { // @Tags 插件-Gitea // @Produce json // @Security BearerToken -// @Success 200 {object} controllers.SuccessResponse +// @Success 200 {object} controllers.SuccessResponse // @Router /plugins/gitea/stop [post] func (r *GiteaController) Stop(ctx http.Context) http.Response { if err := tools.ServiceStop("gitea"); err != nil { @@ -153,7 +153,7 @@ func (r *GiteaController) Stop(ctx http.Context) http.Response { // @Tags 插件-Gitea // @Produce json // @Security BearerToken -// @Success 200 {object} controllers.SuccessResponse +// @Success 200 {object} controllers.SuccessResponse // @Router /plugins/gitea/config [get] func (r *GiteaController) GetConfig(ctx http.Context) http.Response { config, err := tools.Read("/www/server/gitea/app.ini") diff --git a/docs/docs.go b/docs/docs.go index ffbc079a..497117fd 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3551,6 +3551,31 @@ const docTemplate = `{ } } }, + "/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": [ @@ -3684,6 +3709,240 @@ const docTemplate = `{ } } }, + "/plugins/gitea/config": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Gitea 配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Gitea" + ], + "summary": "获取配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "更新 Gitea 配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Gitea" + ], + "summary": "更新配置", + "parameters": [ + { + "description": "request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_TheTNB_panel_app_http_requests_plugins_gitea.UpdateConfig" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/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/rsync/config": { "get": { "security": [ @@ -4075,6 +4334,14 @@ const docTemplate = `{ } } }, + "github_com_TheTNB_panel_app_http_requests_plugins_gitea.UpdateConfig": { + "type": "object", + "properties": { + "config": { + "type": "string" + } + } + }, "github_com_TheTNB_panel_app_http_requests_plugins_rsync.Update": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index d6b30546..31247122 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3544,6 +3544,31 @@ } } }, + "/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": [ @@ -3677,6 +3702,240 @@ } } }, + "/plugins/gitea/config": { + "get": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "获取 Gitea 配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Gitea" + ], + "summary": "获取配置", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + }, + "post": { + "security": [ + { + "BearerToken": [] + } + ], + "description": "更新 Gitea 配置", + "produces": [ + "application/json" + ], + "tags": [ + "插件-Gitea" + ], + "summary": "更新配置", + "parameters": [ + { + "description": "request", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_TheTNB_panel_app_http_requests_plugins_gitea.UpdateConfig" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controllers.SuccessResponse" + } + } + } + } + }, + "/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/rsync/config": { "get": { "security": [ @@ -4068,6 +4327,14 @@ } } }, + "github_com_TheTNB_panel_app_http_requests_plugins_gitea.UpdateConfig": { + "type": "object", + "properties": { + "config": { + "type": "string" + } + } + }, "github_com_TheTNB_panel_app_http_requests_plugins_rsync.Update": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d13777f1..90a533cc 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -43,6 +43,11 @@ definitions: service: type: string type: object + github_com_TheTNB_panel_app_http_requests_plugins_gitea.UpdateConfig: + properties: + config: + type: string + type: object github_com_TheTNB_panel_app_http_requests_plugins_rsync.Update: properties: auth_user: @@ -2811,6 +2816,21 @@ paths: 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 服务 @@ -2892,6 +2912,147 @@ paths: summary: 停止服务 tags: - 插件-Frp + /plugins/gitea/config: + get: + description: 获取 Gitea 配置 + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + summary: 获取配置 + tags: + - 插件-Gitea + post: + description: 更新 Gitea 配置 + parameters: + - description: request + in: body + name: data + required: true + schema: + $ref: '#/definitions/github_com_TheTNB_panel_app_http_requests_plugins_gitea.UpdateConfig' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controllers.SuccessResponse' + security: + - BearerToken: [] + 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/rsync/config: get: description: 获取 Rsync 配置