mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 19:37:18 +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/app/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/app/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/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
@@ -69,7 +69,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
user := services.NewUserImpl()
|
||||
user := services2.NewUserImpl()
|
||||
_, err = user.Create("admin", hash)
|
||||
if err != nil {
|
||||
color.Redln("创建管理员失败")
|
||||
@@ -268,7 +268,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
|
||||
color.Greenln("|-备份成功")
|
||||
|
||||
case "mysql":
|
||||
rootPassword := services.NewSettingImpl().Get(models.SettingKeyMysqlRootPassword)
|
||||
rootPassword := services2.NewSettingImpl().Get(models.SettingKeyMysqlRootPassword)
|
||||
backupFile := name + "_" + carbon.Now().ToShortDateTimeString() + ".sql"
|
||||
|
||||
err := os.Setenv("MYSQL_PWD", rootPassword)
|
||||
|
||||
@@ -7,12 +7,13 @@ import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/services"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type AssetController struct {
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewAssetController() *AssetController {
|
||||
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
requests "panel/app/http/requests/cert"
|
||||
commonrequests "panel/app/http/requests/common"
|
||||
responses "panel/app/http/responses/cert"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/acme"
|
||||
)
|
||||
|
||||
type CertController struct {
|
||||
cron services.Cron
|
||||
cert services.Cert
|
||||
cron internal.Cron
|
||||
cert internal.Cert
|
||||
}
|
||||
|
||||
func NewCertController() *CertController {
|
||||
|
||||
@@ -8,14 +8,16 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type CronController struct {
|
||||
cron services.Cron
|
||||
setting services.Setting
|
||||
cron internal.Cron
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewCronController() *CronController {
|
||||
|
||||
@@ -9,8 +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/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
@@ -22,8 +23,8 @@ type MenuItem struct {
|
||||
}
|
||||
|
||||
type InfoController struct {
|
||||
plugin services.Plugin
|
||||
setting services.Setting
|
||||
plugin internal.Plugin
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewInfoController() *InfoController {
|
||||
@@ -60,7 +61,7 @@ func (r *InfoController) HomePlugins(ctx http.Context) http.Response {
|
||||
for _, plugin := range plugins {
|
||||
pluginsJson = append(pluginsJson, pluginsData{
|
||||
Plugin: plugin,
|
||||
Name: services.NewPluginImpl().GetBySlug(plugin.Slug).Name,
|
||||
Name: r.plugin.GetBySlug(plugin.Slug).Name,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
)
|
||||
|
||||
type MonitorController struct {
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewMonitorController() *MonitorController {
|
||||
|
||||
@@ -6,13 +6,14 @@ import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
)
|
||||
|
||||
type PluginController struct {
|
||||
plugin services.Plugin
|
||||
task services.Task
|
||||
plugin internal.Plugin
|
||||
task internal.Task
|
||||
}
|
||||
|
||||
func NewPluginController() *PluginController {
|
||||
|
||||
@@ -9,13 +9,14 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Fail2banController struct {
|
||||
website services.Website
|
||||
website internal.Website
|
||||
}
|
||||
|
||||
func NewFail2banController() *Fail2banController {
|
||||
|
||||
@@ -9,14 +9,15 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Mysql57Controller struct {
|
||||
setting services.Setting
|
||||
backup services.Backup
|
||||
setting internal.Setting
|
||||
backup internal.Backup
|
||||
}
|
||||
|
||||
func NewMysql57Controller() *Mysql57Controller {
|
||||
@@ -376,7 +377,7 @@ func (r *Mysql57Controller) BackupList(ctx http.Context) http.Response {
|
||||
if startIndex > len(backupList) {
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
"items": []internal.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
@@ -384,7 +385,7 @@ func (r *Mysql57Controller) BackupList(ctx http.Context) http.Response {
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
pagedBackupList = []internal.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
|
||||
@@ -7,16 +7,17 @@ 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/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Mysql80Controller struct {
|
||||
setting services.Setting
|
||||
backup services.Backup
|
||||
setting internal.Setting
|
||||
backup internal.Backup
|
||||
}
|
||||
|
||||
func NewMysql80Controller() *Mysql80Controller {
|
||||
@@ -376,7 +377,7 @@ func (r *Mysql80Controller) BackupList(ctx http.Context) http.Response {
|
||||
if startIndex > len(backupList) {
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
"items": []internal.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
@@ -384,7 +385,7 @@ func (r *Mysql80Controller) BackupList(ctx http.Context) http.Response {
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
pagedBackupList = []internal.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Php74Controller struct {
|
||||
setting services.Setting
|
||||
task services.Task
|
||||
setting internal.Setting
|
||||
task internal.Task
|
||||
version string
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Php80Controller struct {
|
||||
setting services.Setting
|
||||
task services.Task
|
||||
setting internal.Setting
|
||||
task internal.Task
|
||||
version string
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Php81Controller struct {
|
||||
setting services.Setting
|
||||
task services.Task
|
||||
setting internal.Setting
|
||||
task internal.Task
|
||||
version string
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Php82Controller struct {
|
||||
setting services.Setting
|
||||
task services.Task
|
||||
setting internal.Setting
|
||||
task internal.Task
|
||||
version string
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"github.com/imroc/req/v3"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Php83Controller struct {
|
||||
setting services.Setting
|
||||
task services.Task
|
||||
setting internal.Setting
|
||||
task internal.Task
|
||||
version string
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Postgresql15Controller struct {
|
||||
setting services.Setting
|
||||
backup services.Backup
|
||||
setting internal.Setting
|
||||
backup internal.Backup
|
||||
}
|
||||
|
||||
func NewPostgresql15Controller() *Postgresql15Controller {
|
||||
@@ -319,7 +320,7 @@ func (r *Postgresql15Controller) BackupList(ctx http.Context) http.Response {
|
||||
if startIndex > len(backupList) {
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
"items": []internal.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
@@ -327,7 +328,7 @@ func (r *Postgresql15Controller) BackupList(ctx http.Context) http.Response {
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
pagedBackupList = []internal.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Postgresql16Controller struct {
|
||||
setting services.Setting
|
||||
backup services.Backup
|
||||
setting internal.Setting
|
||||
backup internal.Backup
|
||||
}
|
||||
|
||||
func NewPostgresql16Controller() *Postgresql16Controller {
|
||||
@@ -319,7 +320,7 @@ func (r *Postgresql16Controller) BackupList(ctx http.Context) http.Response {
|
||||
if startIndex > len(backupList) {
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
"items": []internal.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
@@ -327,7 +328,7 @@ func (r *Postgresql16Controller) BackupList(ctx http.Context) http.Response {
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
pagedBackupList = []internal.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
|
||||
@@ -9,12 +9,13 @@ import (
|
||||
"panel/app/http/controllers"
|
||||
commonrequests "panel/app/http/requests/common"
|
||||
requests "panel/app/http/requests/plugins/rsync"
|
||||
"panel/app/services"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type RsyncController struct {
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewRsyncController() *RsyncController {
|
||||
|
||||
@@ -9,12 +9,13 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/services"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type S3fsController struct {
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewS3fsController() *S3fsController {
|
||||
|
||||
@@ -7,13 +7,14 @@ import (
|
||||
|
||||
requests "panel/app/http/requests/setting"
|
||||
responses "panel/app/http/responses/setting"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type SettingController struct {
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewSettingController() *SettingController {
|
||||
|
||||
@@ -13,14 +13,15 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
"github.com/valyala/fasthttp"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/ssh"
|
||||
)
|
||||
|
||||
type SshController struct {
|
||||
AuthMethod ssh.AuthMethod
|
||||
setting services.Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewSshController() *SshController {
|
||||
|
||||
@@ -11,15 +11,16 @@ import (
|
||||
commonrequests "panel/app/http/requests/common"
|
||||
requests "panel/app/http/requests/website"
|
||||
responses "panel/app/http/responses/website"
|
||||
"panel/app/internal"
|
||||
"panel/app/internal/services"
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type WebsiteController struct {
|
||||
website services.Website
|
||||
setting services.Setting
|
||||
backup services.Backup
|
||||
website internal.Website
|
||||
setting internal.Setting
|
||||
backup internal.Backup
|
||||
}
|
||||
|
||||
func NewWebsiteController() *WebsiteController {
|
||||
@@ -83,7 +84,7 @@ func (r *WebsiteController) Add(ctx http.Context) http.Response {
|
||||
addRequest.Path = r.setting.Get(models.SettingKeyWebsitePath) + "/" + addRequest.Name
|
||||
}
|
||||
|
||||
website := services.PanelWebsite{
|
||||
website := internal.PanelWebsite{
|
||||
Name: addRequest.Name,
|
||||
Status: true,
|
||||
Domains: addRequest.Domains,
|
||||
@@ -350,7 +351,7 @@ func (r *WebsiteController) BackupList(ctx http.Context) http.Response {
|
||||
if startIndex > len(backupList) {
|
||||
return Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
"items": []internal.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
@@ -358,7 +359,7 @@ func (r *WebsiteController) BackupList(ctx http.Context) http.Response {
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
pagedBackupList = []internal.BackupFile{}
|
||||
}
|
||||
|
||||
return Success(ctx, http.Json{
|
||||
|
||||
@@ -5,8 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
|
||||
"panel/app/services"
|
||||
"panel/app/internal/services"
|
||||
)
|
||||
|
||||
// MustInstall 确保已安装插件
|
||||
|
||||
20
app/internal/backup.go
Normal file
20
app/internal/backup.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package internal
|
||||
|
||||
import "panel/app/models"
|
||||
|
||||
type Backup interface {
|
||||
WebsiteList() ([]BackupFile, error)
|
||||
WebSiteBackup(website models.Website) error
|
||||
WebsiteRestore(website models.Website, backupFile string) error
|
||||
MysqlList() ([]BackupFile, error)
|
||||
MysqlBackup(database string) error
|
||||
MysqlRestore(database string, backupFile string) error
|
||||
PostgresqlList() ([]BackupFile, error)
|
||||
PostgresqlBackup(database string) error
|
||||
PostgresqlRestore(database string, backupFile string) error
|
||||
}
|
||||
|
||||
type BackupFile struct {
|
||||
Name string `json:"name"`
|
||||
Size string `json:"size"`
|
||||
}
|
||||
28
app/internal/cert.go
Normal file
28
app/internal/cert.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"github.com/go-acme/lego/v4/certificate"
|
||||
|
||||
requests "panel/app/http/requests/cert"
|
||||
"panel/app/models"
|
||||
"panel/pkg/acme"
|
||||
)
|
||||
|
||||
type Cert interface {
|
||||
UserStore(request requests.UserStore) error
|
||||
UserUpdate(request requests.UserUpdate) error
|
||||
UserShow(ID uint) (models.CertUser, error)
|
||||
UserDestroy(ID uint) error
|
||||
DNSStore(request requests.DNSStore) error
|
||||
DNSUpdate(request requests.DNSUpdate) error
|
||||
DNSShow(ID uint) (models.CertDNS, error)
|
||||
DNSDestroy(ID uint) error
|
||||
CertStore(request requests.CertStore) error
|
||||
CertUpdate(request requests.CertUpdate) error
|
||||
CertShow(ID uint) (models.Cert, error)
|
||||
CertDestroy(ID uint) error
|
||||
ObtainAuto(ID uint) (certificate.Resource, error)
|
||||
ObtainManual(ID uint) (certificate.Resource, error)
|
||||
ManualDNS(ID uint) (map[string]acme.Resolve, error)
|
||||
Renew(ID uint) (certificate.Resource, error)
|
||||
}
|
||||
8
app/internal/cron.go
Normal file
8
app/internal/cron.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package internal
|
||||
|
||||
import "panel/app/models"
|
||||
|
||||
type Cron interface {
|
||||
AddToSystem(cron models.Cron) error
|
||||
DeleteFromSystem(cron models.Cron) error
|
||||
}
|
||||
23
app/internal/plugin.go
Normal file
23
app/internal/plugin.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package internal
|
||||
|
||||
import "panel/app/models"
|
||||
|
||||
// PanelPlugin 插件元数据结构
|
||||
type PanelPlugin struct {
|
||||
Name string
|
||||
Description string
|
||||
Slug string
|
||||
Version string
|
||||
Requires []string
|
||||
Excludes []string
|
||||
Install string
|
||||
Uninstall string
|
||||
Update string
|
||||
}
|
||||
|
||||
type Plugin interface {
|
||||
AllInstalled() ([]models.Plugin, error)
|
||||
All() []PanelPlugin
|
||||
GetBySlug(slug string) PanelPlugin
|
||||
GetInstalledBySlug(slug string) models.Plugin
|
||||
}
|
||||
@@ -9,29 +9,13 @@ import (
|
||||
|
||||
"github.com/goravel/framework/support/carbon"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/models"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Backup interface {
|
||||
WebsiteList() ([]BackupFile, error)
|
||||
WebSiteBackup(website models.Website) error
|
||||
WebsiteRestore(website models.Website, backupFile string) error
|
||||
MysqlList() ([]BackupFile, error)
|
||||
MysqlBackup(database string) error
|
||||
MysqlRestore(database string, backupFile string) error
|
||||
PostgresqlList() ([]BackupFile, error)
|
||||
PostgresqlBackup(database string) error
|
||||
PostgresqlRestore(database string, backupFile string) error
|
||||
}
|
||||
|
||||
type BackupFile struct {
|
||||
Name string `json:"name"`
|
||||
Size string `json:"size"`
|
||||
}
|
||||
|
||||
type BackupImpl struct {
|
||||
setting Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewBackupImpl() *BackupImpl {
|
||||
@@ -41,30 +25,30 @@ func NewBackupImpl() *BackupImpl {
|
||||
}
|
||||
|
||||
// WebsiteList 网站备份列表
|
||||
func (s *BackupImpl) WebsiteList() ([]BackupFile, error) {
|
||||
func (s *BackupImpl) WebsiteList() ([]internal.BackupFile, error) {
|
||||
backupPath := s.setting.Get(models.SettingKeyBackupPath)
|
||||
if len(backupPath) == 0 {
|
||||
return []BackupFile{}, nil
|
||||
return []internal.BackupFile{}, nil
|
||||
}
|
||||
|
||||
backupPath += "/website"
|
||||
if !tools.Exists(backupPath) {
|
||||
if err := tools.Mkdir(backupPath, 0644); err != nil {
|
||||
return []BackupFile{}, err
|
||||
return []internal.BackupFile{}, err
|
||||
}
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(backupPath)
|
||||
if err != nil {
|
||||
return []BackupFile{}, err
|
||||
return []internal.BackupFile{}, err
|
||||
}
|
||||
var backupList []BackupFile
|
||||
var backupList []internal.BackupFile
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
backupList = append(backupList, BackupFile{
|
||||
backupList = append(backupList, internal.BackupFile{
|
||||
Name: file.Name(),
|
||||
Size: tools.FormatBytes(float64(info.Size())),
|
||||
})
|
||||
@@ -131,30 +115,30 @@ func (s *BackupImpl) WebsiteRestore(website models.Website, backupFile string) e
|
||||
}
|
||||
|
||||
// MysqlList MySQL备份列表
|
||||
func (s *BackupImpl) MysqlList() ([]BackupFile, error) {
|
||||
func (s *BackupImpl) MysqlList() ([]internal.BackupFile, error) {
|
||||
backupPath := s.setting.Get(models.SettingKeyBackupPath)
|
||||
if len(backupPath) == 0 {
|
||||
return []BackupFile{}, nil
|
||||
return []internal.BackupFile{}, nil
|
||||
}
|
||||
|
||||
backupPath += "/mysql"
|
||||
if !tools.Exists(backupPath) {
|
||||
if err := tools.Mkdir(backupPath, 0644); err != nil {
|
||||
return []BackupFile{}, err
|
||||
return []internal.BackupFile{}, err
|
||||
}
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(backupPath)
|
||||
if err != nil {
|
||||
return []BackupFile{}, err
|
||||
return []internal.BackupFile{}, err
|
||||
}
|
||||
var backupList []BackupFile
|
||||
var backupList []internal.BackupFile
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
backupList = append(backupList, BackupFile{
|
||||
backupList = append(backupList, internal.BackupFile{
|
||||
Name: file.Name(),
|
||||
Size: tools.FormatBytes(float64(info.Size())),
|
||||
})
|
||||
@@ -244,30 +228,30 @@ func (s *BackupImpl) MysqlRestore(database string, backupFile string) error {
|
||||
}
|
||||
|
||||
// PostgresqlList PostgreSQL备份列表
|
||||
func (s *BackupImpl) PostgresqlList() ([]BackupFile, error) {
|
||||
func (s *BackupImpl) PostgresqlList() ([]internal.BackupFile, error) {
|
||||
backupPath := s.setting.Get(models.SettingKeyBackupPath)
|
||||
if len(backupPath) == 0 {
|
||||
return []BackupFile{}, nil
|
||||
return []internal.BackupFile{}, nil
|
||||
}
|
||||
|
||||
backupPath += "/postgresql"
|
||||
if !tools.Exists(backupPath) {
|
||||
if err := tools.Mkdir(backupPath, 0644); err != nil {
|
||||
return []BackupFile{}, err
|
||||
return []internal.BackupFile{}, err
|
||||
}
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(backupPath)
|
||||
if err != nil {
|
||||
return []BackupFile{}, err
|
||||
return []internal.BackupFile{}, err
|
||||
}
|
||||
var backupList []BackupFile
|
||||
var backupList []internal.BackupFile
|
||||
for _, file := range files {
|
||||
info, err := file.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
backupList = append(backupList, BackupFile{
|
||||
backupList = append(backupList, internal.BackupFile{
|
||||
Name: file.Name(),
|
||||
Size: tools.FormatBytes(float64(info.Size())),
|
||||
})
|
||||
@@ -14,25 +14,6 @@ import (
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Cert interface {
|
||||
UserStore(request requests.UserStore) error
|
||||
UserUpdate(request requests.UserUpdate) error
|
||||
UserShow(ID uint) (models.CertUser, error)
|
||||
UserDestroy(ID uint) error
|
||||
DNSStore(request requests.DNSStore) error
|
||||
DNSUpdate(request requests.DNSUpdate) error
|
||||
DNSShow(ID uint) (models.CertDNS, error)
|
||||
DNSDestroy(ID uint) error
|
||||
CertStore(request requests.CertStore) error
|
||||
CertUpdate(request requests.CertUpdate) error
|
||||
CertShow(ID uint) (models.Cert, error)
|
||||
CertDestroy(ID uint) error
|
||||
ObtainAuto(ID uint) (certificate.Resource, error)
|
||||
ObtainManual(ID uint) (certificate.Resource, error)
|
||||
ManualDNS(ID uint) (map[string]acme.Resolve, error)
|
||||
Renew(ID uint) (certificate.Resource, error)
|
||||
}
|
||||
|
||||
type CertImpl struct {
|
||||
}
|
||||
|
||||
@@ -7,11 +7,6 @@ import (
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Cron interface {
|
||||
AddToSystem(cron models.Cron) error
|
||||
DeleteFromSystem(cron models.Cron) error
|
||||
}
|
||||
|
||||
type CronImpl struct {
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package services
|
||||
import (
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/internal"
|
||||
"panel/app/models"
|
||||
"panel/app/plugins/fail2ban"
|
||||
"panel/app/plugins/mysql57"
|
||||
@@ -25,26 +26,6 @@ import (
|
||||
"panel/app/plugins/toolbox"
|
||||
)
|
||||
|
||||
// PanelPlugin 插件元数据结构
|
||||
type PanelPlugin struct {
|
||||
Name string
|
||||
Description string
|
||||
Slug string
|
||||
Version string
|
||||
Requires []string
|
||||
Excludes []string
|
||||
Install string
|
||||
Uninstall string
|
||||
Update string
|
||||
}
|
||||
|
||||
type Plugin interface {
|
||||
AllInstalled() ([]models.Plugin, error)
|
||||
All() []PanelPlugin
|
||||
GetBySlug(slug string) PanelPlugin
|
||||
GetInstalledBySlug(slug string) models.Plugin
|
||||
}
|
||||
|
||||
type PluginImpl struct {
|
||||
}
|
||||
|
||||
@@ -63,10 +44,10 @@ func (r *PluginImpl) AllInstalled() ([]models.Plugin, error) {
|
||||
}
|
||||
|
||||
// All 获取所有插件
|
||||
func (r *PluginImpl) All() []PanelPlugin {
|
||||
var p []PanelPlugin
|
||||
func (r *PluginImpl) All() []internal.PanelPlugin {
|
||||
var p []internal.PanelPlugin
|
||||
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: openresty.Name,
|
||||
Description: openresty.Description,
|
||||
Slug: openresty.Slug,
|
||||
@@ -77,7 +58,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: openresty.Uninstall,
|
||||
Update: openresty.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: mysql57.Name,
|
||||
Description: mysql57.Description,
|
||||
Slug: mysql57.Slug,
|
||||
@@ -88,7 +69,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: mysql57.Uninstall,
|
||||
Update: mysql57.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: mysql80.Name,
|
||||
Description: mysql80.Description,
|
||||
Slug: mysql80.Slug,
|
||||
@@ -99,7 +80,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: mysql80.Uninstall,
|
||||
Update: mysql80.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: postgresql15.Name,
|
||||
Description: postgresql15.Description,
|
||||
Slug: postgresql15.Slug,
|
||||
@@ -110,7 +91,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: postgresql15.Uninstall,
|
||||
Update: postgresql15.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: postgresql16.Name,
|
||||
Description: postgresql16.Description,
|
||||
Slug: postgresql16.Slug,
|
||||
@@ -121,7 +102,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: postgresql16.Uninstall,
|
||||
Update: postgresql16.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: php74.Name,
|
||||
Description: php74.Description,
|
||||
Slug: php74.Slug,
|
||||
@@ -132,7 +113,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: php74.Uninstall,
|
||||
Update: php74.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: php80.Name,
|
||||
Description: php80.Description,
|
||||
Slug: php80.Slug,
|
||||
@@ -143,7 +124,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: php80.Uninstall,
|
||||
Update: php80.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: php81.Name,
|
||||
Description: php81.Description,
|
||||
Slug: php81.Slug,
|
||||
@@ -154,7 +135,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: php81.Uninstall,
|
||||
Update: php81.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: php82.Name,
|
||||
Description: php82.Description,
|
||||
Slug: php82.Slug,
|
||||
@@ -165,7 +146,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: php82.Uninstall,
|
||||
Update: php82.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: php83.Name,
|
||||
Description: php83.Description,
|
||||
Slug: php83.Slug,
|
||||
@@ -176,7 +157,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: php83.Uninstall,
|
||||
Update: php83.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: phpmyadmin.Name,
|
||||
Description: phpmyadmin.Description,
|
||||
Slug: phpmyadmin.Slug,
|
||||
@@ -187,7 +168,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: phpmyadmin.Uninstall,
|
||||
Update: phpmyadmin.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: pureftpd.Name,
|
||||
Description: pureftpd.Description,
|
||||
Slug: pureftpd.Slug,
|
||||
@@ -198,7 +179,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: pureftpd.Uninstall,
|
||||
Update: pureftpd.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: redis.Name,
|
||||
Description: redis.Description,
|
||||
Slug: redis.Slug,
|
||||
@@ -209,7 +190,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: redis.Uninstall,
|
||||
Update: redis.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: s3fs.Name,
|
||||
Description: s3fs.Description,
|
||||
Slug: s3fs.Slug,
|
||||
@@ -220,7 +201,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: s3fs.Uninstall,
|
||||
Update: s3fs.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: supervisor.Name,
|
||||
Description: supervisor.Description,
|
||||
Slug: supervisor.Slug,
|
||||
@@ -231,7 +212,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: supervisor.Uninstall,
|
||||
Update: supervisor.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: fail2ban.Name,
|
||||
Description: fail2ban.Description,
|
||||
Slug: fail2ban.Slug,
|
||||
@@ -242,7 +223,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: fail2ban.Uninstall,
|
||||
Update: fail2ban.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: rsync.Name,
|
||||
Description: rsync.Description,
|
||||
Slug: rsync.Slug,
|
||||
@@ -253,7 +234,7 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
Uninstall: rsync.Uninstall,
|
||||
Update: rsync.Update,
|
||||
})
|
||||
p = append(p, PanelPlugin{
|
||||
p = append(p, internal.PanelPlugin{
|
||||
Name: toolbox.Name,
|
||||
Description: toolbox.Description,
|
||||
Slug: toolbox.Slug,
|
||||
@@ -269,14 +250,14 @@ func (r *PluginImpl) All() []PanelPlugin {
|
||||
}
|
||||
|
||||
// GetBySlug 根据slug获取插件
|
||||
func (r *PluginImpl) GetBySlug(slug string) PanelPlugin {
|
||||
func (r *PluginImpl) GetBySlug(slug string) internal.PanelPlugin {
|
||||
for _, item := range r.All() {
|
||||
if item.Slug == slug {
|
||||
return item
|
||||
}
|
||||
}
|
||||
|
||||
return PanelPlugin{}
|
||||
return internal.PanelPlugin{}
|
||||
}
|
||||
|
||||
// GetInstalledBySlug 根据slug获取已安装的插件
|
||||
@@ -6,12 +6,6 @@ import (
|
||||
"panel/app/models"
|
||||
)
|
||||
|
||||
type Setting interface {
|
||||
Get(key string, defaultValue ...string) string
|
||||
Set(key, value string) error
|
||||
Delete(key string) error
|
||||
}
|
||||
|
||||
type SettingImpl struct {
|
||||
}
|
||||
|
||||
@@ -7,10 +7,6 @@ import (
|
||||
"panel/app/jobs"
|
||||
)
|
||||
|
||||
type Task interface {
|
||||
Process(taskID uint)
|
||||
}
|
||||
|
||||
type TaskImpl struct {
|
||||
}
|
||||
|
||||
@@ -7,11 +7,6 @@ import (
|
||||
"panel/app/models"
|
||||
)
|
||||
|
||||
type User interface {
|
||||
Create(name, password string) (models.User, error)
|
||||
Update(user models.User) (models.User, error)
|
||||
}
|
||||
|
||||
type UserImpl struct {
|
||||
}
|
||||
|
||||
@@ -13,67 +13,14 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/spf13/cast"
|
||||
requests "panel/app/http/requests/website"
|
||||
"panel/app/internal"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/pkg/tools"
|
||||
)
|
||||
|
||||
type Website interface {
|
||||
List(page int, limit int) (int64, []models.Website, error)
|
||||
Add(website PanelWebsite) (models.Website, error)
|
||||
SaveConfig(config requests.SaveConfig) error
|
||||
Delete(id uint) error
|
||||
GetConfig(id uint) (WebsiteSetting, error)
|
||||
GetConfigByName(name string) (WebsiteSetting, error)
|
||||
}
|
||||
|
||||
type PanelWebsite struct {
|
||||
Name string `json:"name"`
|
||||
Status bool `json:"status"`
|
||||
Domains []string `json:"domains"`
|
||||
Ports []uint `json:"ports"`
|
||||
Path string `json:"path"`
|
||||
Php int `json:"php"`
|
||||
Ssl bool `json:"ssl"`
|
||||
Remark string `json:"remark"`
|
||||
Db bool `json:"db"`
|
||||
DbType string `json:"db_type"`
|
||||
DbName string `json:"db_name"`
|
||||
DbUser string `json:"db_user"`
|
||||
DbPassword string `json:"db_password"`
|
||||
}
|
||||
|
||||
// WebsiteSetting 网站设置
|
||||
type WebsiteSetting struct {
|
||||
Name string `json:"name"`
|
||||
Domains []string `json:"domains"`
|
||||
Ports []uint `json:"ports"`
|
||||
Root string `json:"root"`
|
||||
Path string `json:"path"`
|
||||
Index string `json:"index"`
|
||||
Php int `json:"php"`
|
||||
OpenBasedir bool `json:"open_basedir"`
|
||||
Ssl bool `json:"ssl"`
|
||||
SslCertificate string `json:"ssl_certificate"`
|
||||
SslCertificateKey string `json:"ssl_certificate_key"`
|
||||
SslNotBefore string `json:"ssl_not_before"`
|
||||
SslNotAfter string `json:"ssl_not_after"`
|
||||
SSlDNSNames []string `json:"ssl_dns_names"`
|
||||
SslIssuer string `json:"ssl_issuer"`
|
||||
SslOCSPServer []string `json:"ssl_ocsp_server"`
|
||||
HttpRedirect bool `json:"http_redirect"`
|
||||
Hsts bool `json:"hsts"`
|
||||
Waf bool `json:"waf"`
|
||||
WafMode string `json:"waf_mode"`
|
||||
WafCcDeny string `json:"waf_cc_deny"`
|
||||
WafCache string `json:"waf_cache"`
|
||||
Rewrite string `json:"rewrite"`
|
||||
Raw string `json:"raw"`
|
||||
Log string `json:"log"`
|
||||
}
|
||||
|
||||
type WebsiteImpl struct {
|
||||
setting Setting
|
||||
setting internal.Setting
|
||||
}
|
||||
|
||||
func NewWebsiteImpl() *WebsiteImpl {
|
||||
@@ -94,7 +41,7 @@ func (r *WebsiteImpl) List(page, limit int) (int64, []models.Website, error) {
|
||||
}
|
||||
|
||||
// Add 添加网站
|
||||
func (r *WebsiteImpl) Add(website PanelWebsite) (models.Website, error) {
|
||||
func (r *WebsiteImpl) Add(website internal.PanelWebsite) (models.Website, error) {
|
||||
w := models.Website{
|
||||
Name: website.Name,
|
||||
Status: website.Status,
|
||||
@@ -553,18 +500,18 @@ func (r *WebsiteImpl) Delete(id uint) error {
|
||||
}
|
||||
|
||||
// GetConfig 获取网站配置
|
||||
func (r *WebsiteImpl) GetConfig(id uint) (WebsiteSetting, error) {
|
||||
func (r *WebsiteImpl) GetConfig(id uint) (internal.WebsiteSetting, error) {
|
||||
var website models.Website
|
||||
if err := facades.Orm().Query().Where("id", id).First(&website); err != nil {
|
||||
return WebsiteSetting{}, err
|
||||
return internal.WebsiteSetting{}, err
|
||||
}
|
||||
|
||||
config, err := tools.Read("/www/server/vhost/" + website.Name + ".conf")
|
||||
if err != nil {
|
||||
return WebsiteSetting{}, err
|
||||
return internal.WebsiteSetting{}, err
|
||||
}
|
||||
|
||||
var setting WebsiteSetting
|
||||
var setting internal.WebsiteSetting
|
||||
setting.Name = website.Name
|
||||
setting.Path = website.Path
|
||||
setting.Ssl = website.Ssl
|
||||
@@ -666,10 +613,10 @@ func (r *WebsiteImpl) GetConfig(id uint) (WebsiteSetting, error) {
|
||||
}
|
||||
|
||||
// GetConfigByName 根据网站名称获取网站配置
|
||||
func (r *WebsiteImpl) GetConfigByName(name string) (WebsiteSetting, error) {
|
||||
func (r *WebsiteImpl) GetConfigByName(name string) (internal.WebsiteSetting, error) {
|
||||
var website models.Website
|
||||
if err := facades.Orm().Query().Where("name", name).First(&website); err != nil {
|
||||
return WebsiteSetting{}, err
|
||||
return internal.WebsiteSetting{}, err
|
||||
}
|
||||
|
||||
return r.GetConfig(website.ID)
|
||||
7
app/internal/setting.go
Normal file
7
app/internal/setting.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package internal
|
||||
|
||||
type Setting interface {
|
||||
Get(key string, defaultValue ...string) string
|
||||
Set(key, value string) error
|
||||
Delete(key string) error
|
||||
}
|
||||
5
app/internal/task.go
Normal file
5
app/internal/task.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package internal
|
||||
|
||||
type Task interface {
|
||||
Process(taskID uint)
|
||||
}
|
||||
8
app/internal/user.go
Normal file
8
app/internal/user.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package internal
|
||||
|
||||
import "panel/app/models"
|
||||
|
||||
type User interface {
|
||||
Create(name, password string) (models.User, error)
|
||||
Update(user models.User) (models.User, error)
|
||||
}
|
||||
60
app/internal/website.go
Normal file
60
app/internal/website.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
requests "panel/app/http/requests/website"
|
||||
"panel/app/models"
|
||||
)
|
||||
|
||||
type Website interface {
|
||||
List(page int, limit int) (int64, []models.Website, error)
|
||||
Add(website PanelWebsite) (models.Website, error)
|
||||
SaveConfig(config requests.SaveConfig) error
|
||||
Delete(id uint) error
|
||||
GetConfig(id uint) (WebsiteSetting, error)
|
||||
GetConfigByName(name string) (WebsiteSetting, error)
|
||||
}
|
||||
|
||||
type PanelWebsite struct {
|
||||
Name string `json:"name"`
|
||||
Status bool `json:"status"`
|
||||
Domains []string `json:"domains"`
|
||||
Ports []uint `json:"ports"`
|
||||
Path string `json:"path"`
|
||||
Php int `json:"php"`
|
||||
Ssl bool `json:"ssl"`
|
||||
Remark string `json:"remark"`
|
||||
Db bool `json:"db"`
|
||||
DbType string `json:"db_type"`
|
||||
DbName string `json:"db_name"`
|
||||
DbUser string `json:"db_user"`
|
||||
DbPassword string `json:"db_password"`
|
||||
}
|
||||
|
||||
// WebsiteSetting 网站设置
|
||||
type WebsiteSetting struct {
|
||||
Name string `json:"name"`
|
||||
Domains []string `json:"domains"`
|
||||
Ports []uint `json:"ports"`
|
||||
Root string `json:"root"`
|
||||
Path string `json:"path"`
|
||||
Index string `json:"index"`
|
||||
Php int `json:"php"`
|
||||
OpenBasedir bool `json:"open_basedir"`
|
||||
Ssl bool `json:"ssl"`
|
||||
SslCertificate string `json:"ssl_certificate"`
|
||||
SslCertificateKey string `json:"ssl_certificate_key"`
|
||||
SslNotBefore string `json:"ssl_not_before"`
|
||||
SslNotAfter string `json:"ssl_not_after"`
|
||||
SSlDNSNames []string `json:"ssl_dns_names"`
|
||||
SslIssuer string `json:"ssl_issuer"`
|
||||
SslOCSPServer []string `json:"ssl_ocsp_server"`
|
||||
HttpRedirect bool `json:"http_redirect"`
|
||||
Hsts bool `json:"hsts"`
|
||||
Waf bool `json:"waf"`
|
||||
WafMode string `json:"waf_mode"`
|
||||
WafCcDeny string `json:"waf_cc_deny"`
|
||||
WafCache string `json:"waf_cache"`
|
||||
Rewrite string `json:"rewrite"`
|
||||
Raw string `json:"raw"`
|
||||
Log string `json:"log"`
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/app/services"
|
||||
"panel/tests"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/goravel/framework/facades"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"panel/app/internal/services"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/app/services"
|
||||
"panel/tests"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user