mirror of
https://github.com/acepanel/panel.git
synced 2026-02-05 05:47:17 +08:00
refactor: 移动服务到根目录
This commit is contained in:
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/goravel/framework/contracts/console/command"
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/internal/services"
|
||||
)
|
||||
|
||||
type CertRenew struct {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"github.com/spf13/cast"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"github.com/spf13/cast"
|
||||
services2 "panel/app/internal/services"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
@@ -69,7 +69,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
user := services2.NewUserImpl()
|
||||
user := services.NewUserImpl()
|
||||
_, err = user.Create("admin", hash)
|
||||
if err != nil {
|
||||
color.Redln("创建管理员失败")
|
||||
@@ -276,7 +276,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
color.Greenln("|-备份成功")
|
||||
|
||||
case "mysql":
|
||||
rootPassword := services2.NewSettingImpl().Get(models.SettingKeyMysqlRootPassword)
|
||||
rootPassword := services.NewSettingImpl().Get(models.SettingKeyMysqlRootPassword)
|
||||
backupFile := name + "_" + carbon.Now().ToShortDateTimeString() + ".sql"
|
||||
|
||||
err := os.Setenv("MYSQL_PWD", rootPassword)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
requests "panel/app/http/requests/cert"
|
||||
commonrequests "panel/app/http/requests/common"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/acme"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
)
|
||||
|
||||
type MonitorController struct {
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
)
|
||||
|
||||
type PluginController struct {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/spf13/cast"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"panel/app/http/controllers"
|
||||
commonrequests "panel/app/http/requests/common"
|
||||
requests "panel/app/http/requests/plugins/rsync"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
requests "panel/app/http/requests/setting"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/ssh"
|
||||
)
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
commonrequests "panel/app/http/requests/common"
|
||||
requests "panel/app/http/requests/website"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/internal/services"
|
||||
)
|
||||
|
||||
// MustInstall 确保已安装插件
|
||||
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
internal2 "panel/internal"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/models"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type BackupImpl struct {
|
||||
setting internal.Setting
|
||||
setting internal2.Setting
|
||||
}
|
||||
|
||||
func NewBackupImpl() *BackupImpl {
|
||||
@@ -25,30 +25,30 @@ func NewBackupImpl() *BackupImpl {
|
||||
}
|
||||
|
||||
// WebsiteList 网站备份列表
|
||||
func (s *BackupImpl) WebsiteList() ([]internal.BackupFile, error) {
|
||||
func (s *BackupImpl) WebsiteList() ([]internal2.BackupFile, error) {
|
||||
backupPath := s.setting.Get(models.SettingKeyBackupPath)
|
||||
if len(backupPath) == 0 {
|
||||
return []internal.BackupFile{}, nil
|
||||
return []internal2.BackupFile{}, nil
|
||||
}
|
||||
|
||||
backupPath += "/website"
|
||||
if !tools.Exists(backupPath) {
|
||||
if err := tools.Mkdir(backupPath, 0644); err != nil {
|
||||
return []internal.BackupFile{}, err
|
||||
return []internal2.BackupFile{}, err
|
||||
}
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(backupPath)
|
||||
if err != nil {
|
||||
return []internal.BackupFile{}, err
|
||||
return []internal2.BackupFile{}, err
|
||||
}
|
||||
var backupList []internal.BackupFile
|
||||
var backupList []internal2.BackupFile
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
backupList = append(backupList, internal.BackupFile{
|
||||
backupList = append(backupList, internal2.BackupFile{
|
||||
Name: file.Name(),
|
||||
Size: tools.FormatBytes(float64(info.Size())),
|
||||
})
|
||||
@@ -115,30 +115,30 @@ func (s *BackupImpl) WebsiteRestore(website models.Website, backupFile string) e
|
||||
}
|
||||
|
||||
// MysqlList MySQL备份列表
|
||||
func (s *BackupImpl) MysqlList() ([]internal.BackupFile, error) {
|
||||
func (s *BackupImpl) MysqlList() ([]internal2.BackupFile, error) {
|
||||
backupPath := s.setting.Get(models.SettingKeyBackupPath)
|
||||
if len(backupPath) == 0 {
|
||||
return []internal.BackupFile{}, nil
|
||||
return []internal2.BackupFile{}, nil
|
||||
}
|
||||
|
||||
backupPath += "/mysql"
|
||||
if !tools.Exists(backupPath) {
|
||||
if err := tools.Mkdir(backupPath, 0644); err != nil {
|
||||
return []internal.BackupFile{}, err
|
||||
return []internal2.BackupFile{}, err
|
||||
}
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(backupPath)
|
||||
if err != nil {
|
||||
return []internal.BackupFile{}, err
|
||||
return []internal2.BackupFile{}, err
|
||||
}
|
||||
var backupList []internal.BackupFile
|
||||
var backupList []internal2.BackupFile
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
backupList = append(backupList, internal.BackupFile{
|
||||
backupList = append(backupList, internal2.BackupFile{
|
||||
Name: file.Name(),
|
||||
Size: tools.FormatBytes(float64(info.Size())),
|
||||
})
|
||||
@@ -228,30 +228,30 @@ func (s *BackupImpl) MysqlRestore(database string, backupFile string) error {
|
||||
}
|
||||
|
||||
// PostgresqlList PostgreSQL备份列表
|
||||
func (s *BackupImpl) PostgresqlList() ([]internal.BackupFile, error) {
|
||||
func (s *BackupImpl) PostgresqlList() ([]internal2.BackupFile, error) {
|
||||
backupPath := s.setting.Get(models.SettingKeyBackupPath)
|
||||
if len(backupPath) == 0 {
|
||||
return []internal.BackupFile{}, nil
|
||||
return []internal2.BackupFile{}, nil
|
||||
}
|
||||
|
||||
backupPath += "/postgresql"
|
||||
if !tools.Exists(backupPath) {
|
||||
if err := tools.Mkdir(backupPath, 0644); err != nil {
|
||||
return []internal.BackupFile{}, err
|
||||
return []internal2.BackupFile{}, err
|
||||
}
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(backupPath)
|
||||
if err != nil {
|
||||
return []internal.BackupFile{}, err
|
||||
return []internal2.BackupFile{}, err
|
||||
}
|
||||
var backupList []internal.BackupFile
|
||||
var backupList []internal2.BackupFile
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
backupList = append(backupList, internal.BackupFile{
|
||||
backupList = append(backupList, internal2.BackupFile{
|
||||
Name: file.Name(),
|
||||
Size: tools.FormatBytes(float64(info.Size())),
|
||||
})
|
||||
@@ -3,27 +3,27 @@ package services
|
||||
|
||||
import (
|
||||
"github.com/goravel/framework/facades"
|
||||
"panel/internal"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/models"
|
||||
"panel/app/plugins/fail2ban"
|
||||
"panel/app/plugins/mysql57"
|
||||
"panel/app/plugins/mysql80"
|
||||
"panel/app/plugins/openresty"
|
||||
"panel/app/plugins/php74"
|
||||
"panel/app/plugins/php80"
|
||||
"panel/app/plugins/php81"
|
||||
"panel/app/plugins/php82"
|
||||
"panel/app/plugins/php83"
|
||||
"panel/app/plugins/phpmyadmin"
|
||||
"panel/app/plugins/postgresql15"
|
||||
"panel/app/plugins/postgresql16"
|
||||
"panel/app/plugins/pureftpd"
|
||||
"panel/app/plugins/redis"
|
||||
"panel/app/plugins/rsync"
|
||||
"panel/app/plugins/s3fs"
|
||||
"panel/app/plugins/supervisor"
|
||||
"panel/app/plugins/toolbox"
|
||||
"panel/internal/plugins/fail2ban"
|
||||
"panel/internal/plugins/mysql57"
|
||||
"panel/internal/plugins/mysql80"
|
||||
"panel/internal/plugins/openresty"
|
||||
"panel/internal/plugins/php74"
|
||||
"panel/internal/plugins/php80"
|
||||
"panel/internal/plugins/php81"
|
||||
"panel/internal/plugins/php82"
|
||||
"panel/internal/plugins/php83"
|
||||
"panel/internal/plugins/phpmyadmin"
|
||||
"panel/internal/plugins/postgresql15"
|
||||
"panel/internal/plugins/postgresql16"
|
||||
"panel/internal/plugins/pureftpd"
|
||||
"panel/internal/plugins/redis"
|
||||
"panel/internal/plugins/rsync"
|
||||
"panel/internal/plugins/s3fs"
|
||||
"panel/internal/plugins/supervisor"
|
||||
"panel/internal/plugins/toolbox"
|
||||
)
|
||||
|
||||
type PluginImpl struct {
|
||||
@@ -13,14 +13,14 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/spf13/cast"
|
||||
requests "panel/app/http/requests/website"
|
||||
"panel/app/internal"
|
||||
internal2 "panel/internal"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type WebsiteImpl struct {
|
||||
setting internal.Setting
|
||||
setting internal2.Setting
|
||||
}
|
||||
|
||||
func NewWebsiteImpl() *WebsiteImpl {
|
||||
@@ -41,7 +41,7 @@ func (r *WebsiteImpl) List(page, limit int) (int64, []models.Website, error) {
|
||||
}
|
||||
|
||||
// Add 添加网站
|
||||
func (r *WebsiteImpl) Add(website internal.PanelWebsite) (models.Website, error) {
|
||||
func (r *WebsiteImpl) Add(website internal2.PanelWebsite) (models.Website, error) {
|
||||
w := models.Website{
|
||||
Name: website.Name,
|
||||
Status: website.Status,
|
||||
@@ -500,18 +500,18 @@ func (r *WebsiteImpl) Delete(id uint) error {
|
||||
}
|
||||
|
||||
// GetConfig 获取网站配置
|
||||
func (r *WebsiteImpl) GetConfig(id uint) (internal.WebsiteSetting, error) {
|
||||
func (r *WebsiteImpl) GetConfig(id uint) (internal2.WebsiteSetting, error) {
|
||||
var website models.Website
|
||||
if err := facades.Orm().Query().Where("id", id).First(&website); err != nil {
|
||||
return internal.WebsiteSetting{}, err
|
||||
return internal2.WebsiteSetting{}, err
|
||||
}
|
||||
|
||||
config, err := tools.Read("/www/server/vhost/" + website.Name + ".conf")
|
||||
if err != nil {
|
||||
return internal.WebsiteSetting{}, err
|
||||
return internal2.WebsiteSetting{}, err
|
||||
}
|
||||
|
||||
var setting internal.WebsiteSetting
|
||||
var setting internal2.WebsiteSetting
|
||||
setting.Name = website.Name
|
||||
setting.Path = website.Path
|
||||
setting.Ssl = website.Ssl
|
||||
@@ -613,10 +613,10 @@ func (r *WebsiteImpl) GetConfig(id uint) (internal.WebsiteSetting, error) {
|
||||
}
|
||||
|
||||
// GetConfigByName 根据网站名称获取网站配置
|
||||
func (r *WebsiteImpl) GetConfigByName(name string) (internal.WebsiteSetting, error) {
|
||||
func (r *WebsiteImpl) GetConfigByName(name string) (internal2.WebsiteSetting, error) {
|
||||
var website models.Website
|
||||
if err := facades.Orm().Query().Where("name", name).First(&website); err != nil {
|
||||
return internal.WebsiteSetting{}, err
|
||||
return internal2.WebsiteSetting{}, err
|
||||
}
|
||||
|
||||
return r.GetConfig(website.ID)
|
||||
@@ -4,15 +4,16 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/internal"
|
||||
"panel/internal/services"
|
||||
"panel/tests"
|
||||
)
|
||||
|
||||
type SettingTestSuite struct {
|
||||
suite.Suite
|
||||
tests.TestCase
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func TestSettingTestSuite(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user