Skip to content

Commit

Permalink
refactor: plugin dir
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jul 9, 2023
1 parent b9b1735 commit 200d763
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugins
package openresty

import (
"os"
Expand All @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
11 changes: 11 additions & 0 deletions app/plugins/mysql57/mysql57.go
Original file line number Diff line number Diff line change
@@ -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"}
)
11 changes: 11 additions & 0 deletions app/plugins/mysql80/mysql80.go
Original file line number Diff line number Diff line change
@@ -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"}
)
File renamed without changes.
11 changes: 11 additions & 0 deletions app/plugins/php80/php80.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package php80

var (
Name = "PHP-8.0"
Author = "耗子"
Description = "PHP 是世界上最好的语言!"
Slug = "php80"
Version = "8.0.29"
Requires = []string{}
Excludes = []string{}
)
2 changes: 1 addition & 1 deletion app/services/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/goravel/framework/facades"

"panel/app/models"
"panel/plugins/openresty"
"panel/app/plugins/openresty"
)

// PanelPlugin 插件元数据结构
Expand Down
4 changes: 2 additions & 2 deletions routes/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 200d763

Please sign in to comment.