From 200d763ba430d83d5ebb7173cb79ac9e741ad522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 10 Jul 2023 01:43:16 +0800 Subject: [PATCH] refactor: plugin dir --- .../{ => openresty}/openresty_controller.go | 27 ++++++++++--------- app/plugins/mysql57/mysql57.go | 11 ++++++++ app/plugins/mysql80/mysql80.go | 11 ++++++++ .../plugins}/openresty/openresty.go | 0 app/plugins/php80/php80.go | 11 ++++++++ app/services/plugin.go | 2 +- routes/plugin.go | 4 +-- 7 files changed, 50 insertions(+), 16 deletions(-) rename app/http/controllers/plugins/{ => openresty}/openresty_controller.go (95%) create mode 100644 app/plugins/mysql57/mysql57.go create mode 100644 app/plugins/mysql80/mysql80.go rename {plugins => app/plugins}/openresty/openresty.go (100%) create mode 100644 app/plugins/php80/php80.go diff --git a/app/http/controllers/plugins/openresty_controller.go b/app/http/controllers/plugins/openresty/openresty_controller.go similarity index 95% rename from app/http/controllers/plugins/openresty_controller.go rename to app/http/controllers/plugins/openresty/openresty_controller.go index 8d21921a0e..6b73a5c38f 100644 --- a/app/http/controllers/plugins/openresty_controller.go +++ b/app/http/controllers/plugins/openresty/openresty_controller.go @@ -1,4 +1,4 @@ -package plugins +package openresty import ( "os" @@ -14,22 +14,23 @@ import ( "github.com/goravel/framework/facades" "panel/app/http/controllers" + "panel/app/http/controllers/plugins" "panel/packages/helpers" ) type OpenRestyController struct { - //Dependent services + // Dependent services } func NewOpenrestyController() *OpenRestyController { return &OpenRestyController{ - //Inject services + // Inject services } } // Status 获取运行状态 func (r *OpenRestyController) Status(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -55,7 +56,7 @@ func (r *OpenRestyController) Status(ctx http.Context) { // Reload 重载配置 func (r *OpenRestyController) Reload(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -90,7 +91,7 @@ func (r *OpenRestyController) Reload(ctx http.Context) { // Start 启动OpenResty func (r *OpenRestyController) Start(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -125,7 +126,7 @@ func (r *OpenRestyController) Start(ctx http.Context) { // Stop 停止OpenResty func (r *OpenRestyController) Stop(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -160,7 +161,7 @@ func (r *OpenRestyController) Stop(ctx http.Context) { // Restart 重启OpenResty func (r *OpenRestyController) Restart(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -195,7 +196,7 @@ func (r *OpenRestyController) Restart(ctx http.Context) { // GetConfig 获取配置 func (r *OpenRestyController) GetConfig(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -210,7 +211,7 @@ func (r *OpenRestyController) GetConfig(ctx http.Context) { // SaveConfig 保存配置 func (r *OpenRestyController) SaveConfig(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -265,7 +266,7 @@ func (r *OpenRestyController) SaveConfig(ctx http.Context) { // ErrorLog 获取错误日志 func (r *OpenRestyController) ErrorLog(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -282,7 +283,7 @@ func (r *OpenRestyController) ErrorLog(ctx http.Context) { // ClearErrorLog 清空错误日志 func (r *OpenRestyController) ClearErrorLog(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } @@ -299,7 +300,7 @@ func (r *OpenRestyController) ClearErrorLog(ctx http.Context) { // Load 获取负载 func (r *OpenRestyController) Load(ctx http.Context) { - if !Check(ctx, "openresty") { + if !plugins.Check(ctx, "openresty") { return } diff --git a/app/plugins/mysql57/mysql57.go b/app/plugins/mysql57/mysql57.go new file mode 100644 index 0000000000..fb245f1879 --- /dev/null +++ b/app/plugins/mysql57/mysql57.go @@ -0,0 +1,11 @@ +package mysql57 + +var ( + Name = "MySQL-5.7" + Author = "耗子" + Description = "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。" + Slug = "mysql57" + Version = "5.7.42" + Requires = []string{} + Excludes = []string{"mysql80"} +) diff --git a/app/plugins/mysql80/mysql80.go b/app/plugins/mysql80/mysql80.go new file mode 100644 index 0000000000..7273e854e3 --- /dev/null +++ b/app/plugins/mysql80/mysql80.go @@ -0,0 +1,11 @@ +package mysql80 + +var ( + Name = "MySQL-8.0" + Author = "耗子" + Description = "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。" + Slug = "mysql80" + Version = "8.0.33" + Requires = []string{} + Excludes = []string{"mysql57"} +) diff --git a/plugins/openresty/openresty.go b/app/plugins/openresty/openresty.go similarity index 100% rename from plugins/openresty/openresty.go rename to app/plugins/openresty/openresty.go diff --git a/app/plugins/php80/php80.go b/app/plugins/php80/php80.go new file mode 100644 index 0000000000..e3d1e8ecbe --- /dev/null +++ b/app/plugins/php80/php80.go @@ -0,0 +1,11 @@ +package php80 + +var ( + Name = "PHP-8.0" + Author = "耗子" + Description = "PHP 是世界上最好的语言!" + Slug = "php80" + Version = "8.0.29" + Requires = []string{} + Excludes = []string{} +) diff --git a/app/services/plugin.go b/app/services/plugin.go index 31fac3b198..e42d11966e 100644 --- a/app/services/plugin.go +++ b/app/services/plugin.go @@ -5,7 +5,7 @@ import ( "github.com/goravel/framework/facades" "panel/app/models" - "panel/plugins/openresty" + "panel/app/plugins/openresty" ) // PanelPlugin 插件元数据结构 diff --git a/routes/plugin.go b/routes/plugin.go index 372350691a..44d9d95faa 100644 --- a/routes/plugin.go +++ b/routes/plugin.go @@ -4,14 +4,14 @@ import ( "github.com/goravel/framework/contracts/route" "github.com/goravel/framework/facades" - "panel/app/http/controllers/plugins" + "panel/app/http/controllers/plugins/openresty" "panel/app/http/middleware" ) // Plugin 加载插件路由 func Plugin() { facades.Route().Prefix("api/plugins/openresty").Middleware(middleware.Jwt()).Group(func(route route.Route) { - openRestyController := plugins.NewOpenrestyController() + openRestyController := openresty.NewOpenrestyController() route.Get("status", openRestyController.Status) route.Post("reload", openRestyController.Reload) route.Post("start", openRestyController.Start)