mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 12:40:25 +08:00
feat: 适配前端修改
This commit is contained in:
@@ -477,6 +477,9 @@ func (c *Mysql57Controller) BackupList(ctx http.Context) http.Response {
|
||||
endIndex = len(backupList)
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": len(backupList),
|
||||
|
||||
@@ -477,6 +477,9 @@ func (c *Mysql80Controller) BackupList(ctx http.Context) http.Response {
|
||||
endIndex = len(backupList)
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": len(backupList),
|
||||
|
||||
@@ -371,7 +371,28 @@ func (c *Postgresql15Controller) BackupList(ctx http.Context) http.Response {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取备份列表失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, backupList)
|
||||
page := ctx.Request().QueryInt("page", 1)
|
||||
limit := ctx.Request().QueryInt("limit", 10)
|
||||
startIndex := (page - 1) * limit
|
||||
endIndex := page * limit
|
||||
if startIndex > len(backupList) {
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
endIndex = len(backupList)
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": len(backupList),
|
||||
"items": pagedBackupList,
|
||||
})
|
||||
}
|
||||
|
||||
// UploadBackup 上传备份
|
||||
@@ -459,7 +480,7 @@ func (c *Postgresql15Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
"name": "required|min_len:1|max_len:255",
|
||||
"backup": "required|min_len:1|max_len:255",
|
||||
"database": "required|min_len:1|max_len:255|regex:^[a-zA-Z][a-zA-Z0-9_]+$|not_in:information_schema,mysql,performance_schema,sys",
|
||||
})
|
||||
if err != nil {
|
||||
@@ -469,7 +490,7 @@ func (c *Postgresql15Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}
|
||||
|
||||
err = c.backup.PostgresqlRestore(ctx.Request().Input("database"), ctx.Request().Input("name"))
|
||||
err = c.backup.PostgresqlRestore(ctx.Request().Input("database"), ctx.Request().Input("backup"))
|
||||
if err != nil {
|
||||
facades.Log().Error("[PostgreSQL] 还原失败:" + err.Error())
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "还原失败: "+err.Error())
|
||||
|
||||
@@ -371,7 +371,28 @@ func (c *Postgresql16Controller) BackupList(ctx http.Context) http.Response {
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "获取备份列表失败")
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, backupList)
|
||||
page := ctx.Request().QueryInt("page", 1)
|
||||
limit := ctx.Request().QueryInt("limit", 10)
|
||||
startIndex := (page - 1) * limit
|
||||
endIndex := page * limit
|
||||
if startIndex > len(backupList) {
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": 0,
|
||||
"items": []services.BackupFile{},
|
||||
})
|
||||
}
|
||||
if endIndex > len(backupList) {
|
||||
endIndex = len(backupList)
|
||||
}
|
||||
pagedBackupList := backupList[startIndex:endIndex]
|
||||
if pagedBackupList == nil {
|
||||
pagedBackupList = []services.BackupFile{}
|
||||
}
|
||||
|
||||
return controllers.Success(ctx, http.Json{
|
||||
"total": len(backupList),
|
||||
"items": pagedBackupList,
|
||||
})
|
||||
}
|
||||
|
||||
// UploadBackup 上传备份
|
||||
@@ -459,7 +480,7 @@ func (c *Postgresql16Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
}
|
||||
|
||||
validator, err := ctx.Request().Validate(map[string]string{
|
||||
"name": "required|min_len:1|max_len:255",
|
||||
"backup": "required|min_len:1|max_len:255",
|
||||
"database": "required|min_len:1|max_len:255|regex:^[a-zA-Z][a-zA-Z0-9_]+$|not_in:information_schema,mysql,performance_schema,sys",
|
||||
})
|
||||
if err != nil {
|
||||
@@ -469,7 +490,7 @@ func (c *Postgresql16Controller) RestoreBackup(ctx http.Context) http.Response {
|
||||
return controllers.Error(ctx, http.StatusUnprocessableEntity, validator.Errors().One())
|
||||
}
|
||||
|
||||
err = c.backup.PostgresqlRestore(ctx.Request().Input("database"), ctx.Request().Input("name"))
|
||||
err = c.backup.PostgresqlRestore(ctx.Request().Input("database"), ctx.Request().Input("backup"))
|
||||
if err != nil {
|
||||
facades.Log().Error("[PostgreSQL] 还原失败:" + err.Error())
|
||||
return controllers.Error(ctx, http.StatusInternalServerError, "还原失败: "+err.Error())
|
||||
|
||||
@@ -112,18 +112,18 @@ func Plugin() {
|
||||
route.Post("userConfig", postgresql15Controller.SaveUserConfig)
|
||||
route.Get("log", postgresql15Controller.Log)
|
||||
route.Post("clearLog", postgresql15Controller.ClearLog)
|
||||
route.Get("database", postgresql15Controller.DatabaseList)
|
||||
route.Post("addDatabase", postgresql15Controller.AddDatabase)
|
||||
route.Post("deleteDatabase", postgresql15Controller.DeleteDatabase)
|
||||
route.Get("backup", postgresql15Controller.BackupList)
|
||||
route.Post("createBackup", postgresql15Controller.CreateBackup)
|
||||
route.Post("uploadBackup", postgresql15Controller.UploadBackup)
|
||||
route.Post("deleteBackup", postgresql15Controller.DeleteBackup)
|
||||
route.Post("restoreBackup", postgresql15Controller.RestoreBackup)
|
||||
route.Get("user", postgresql15Controller.UserList)
|
||||
route.Post("addUser", postgresql15Controller.AddUser)
|
||||
route.Post("deleteUser", postgresql15Controller.DeleteUser)
|
||||
route.Post("userPassword", postgresql15Controller.SetUserPassword)
|
||||
route.Get("databases", postgresql15Controller.DatabaseList)
|
||||
route.Post("databases", postgresql15Controller.AddDatabase)
|
||||
route.Delete("databases", postgresql15Controller.DeleteDatabase)
|
||||
route.Get("backups", postgresql15Controller.BackupList)
|
||||
route.Post("backups", postgresql15Controller.CreateBackup)
|
||||
route.Put("backups", postgresql15Controller.UploadBackup)
|
||||
route.Delete("backups", postgresql15Controller.DeleteBackup)
|
||||
route.Post("backups/restore", postgresql15Controller.RestoreBackup)
|
||||
route.Get("users", postgresql15Controller.UserList)
|
||||
route.Post("users", postgresql15Controller.AddUser)
|
||||
route.Delete("users", postgresql15Controller.DeleteUser)
|
||||
route.Post("users/password", postgresql15Controller.SetUserPassword)
|
||||
})
|
||||
facades.Route().Prefix("api/plugins/postgresql16").Middleware(middleware.Jwt()).Group(func(route route.Router) {
|
||||
postgresql16Controller := postgresql16.NewPostgresql16Controller()
|
||||
@@ -139,18 +139,18 @@ func Plugin() {
|
||||
route.Post("userConfig", postgresql16Controller.SaveUserConfig)
|
||||
route.Get("log", postgresql16Controller.Log)
|
||||
route.Post("clearLog", postgresql16Controller.ClearLog)
|
||||
route.Get("database", postgresql16Controller.DatabaseList)
|
||||
route.Post("addDatabase", postgresql16Controller.AddDatabase)
|
||||
route.Post("deleteDatabase", postgresql16Controller.DeleteDatabase)
|
||||
route.Get("backup", postgresql16Controller.BackupList)
|
||||
route.Post("createBackup", postgresql16Controller.CreateBackup)
|
||||
route.Post("uploadBackup", postgresql16Controller.UploadBackup)
|
||||
route.Post("deleteBackup", postgresql16Controller.DeleteBackup)
|
||||
route.Post("restoreBackup", postgresql16Controller.RestoreBackup)
|
||||
route.Get("user", postgresql16Controller.UserList)
|
||||
route.Post("addUser", postgresql16Controller.AddUser)
|
||||
route.Post("deleteUser", postgresql16Controller.DeleteUser)
|
||||
route.Post("userPassword", postgresql16Controller.SetUserPassword)
|
||||
route.Get("databases", postgresql16Controller.DatabaseList)
|
||||
route.Post("databases", postgresql16Controller.AddDatabase)
|
||||
route.Delete("databases", postgresql16Controller.DeleteDatabase)
|
||||
route.Get("backups", postgresql16Controller.BackupList)
|
||||
route.Post("backups", postgresql16Controller.CreateBackup)
|
||||
route.Put("backups", postgresql16Controller.UploadBackup)
|
||||
route.Delete("backups", postgresql16Controller.DeleteBackup)
|
||||
route.Post("backups/restore", postgresql16Controller.RestoreBackup)
|
||||
route.Get("users", postgresql16Controller.UserList)
|
||||
route.Post("users", postgresql16Controller.AddUser)
|
||||
route.Delete("users", postgresql16Controller.DeleteUser)
|
||||
route.Post("users/password", postgresql16Controller.SetUserPassword)
|
||||
})
|
||||
facades.Route().Prefix("api/plugins/php74").Middleware(middleware.Jwt()).Group(func(route route.Router) {
|
||||
php74Controller := php74.NewPhp74Controller()
|
||||
@@ -167,8 +167,8 @@ func Plugin() {
|
||||
route.Post("clearErrorLog", php74Controller.ClearErrorLog)
|
||||
route.Post("clearSlowLog", php74Controller.ClearSlowLog)
|
||||
route.Get("extensions", php74Controller.GetExtensionList)
|
||||
route.Post("installExtension", php74Controller.InstallExtension)
|
||||
route.Post("uninstallExtension", php74Controller.UninstallExtension)
|
||||
route.Post("extensions", php74Controller.InstallExtension)
|
||||
route.Delete("extensions", php74Controller.UninstallExtension)
|
||||
})
|
||||
facades.Route().Prefix("api/plugins/php80").Middleware(middleware.Jwt()).Group(func(route route.Router) {
|
||||
php80Controller := php80.NewPhp80Controller()
|
||||
@@ -185,8 +185,8 @@ func Plugin() {
|
||||
route.Post("clearErrorLog", php80Controller.ClearErrorLog)
|
||||
route.Post("clearSlowLog", php80Controller.ClearSlowLog)
|
||||
route.Get("extensions", php80Controller.GetExtensionList)
|
||||
route.Post("installExtension", php80Controller.InstallExtension)
|
||||
route.Post("uninstallExtension", php80Controller.UninstallExtension)
|
||||
route.Post("extensions", php80Controller.InstallExtension)
|
||||
route.Delete("extensions", php80Controller.UninstallExtension)
|
||||
})
|
||||
facades.Route().Prefix("api/plugins/php81").Middleware(middleware.Jwt()).Group(func(route route.Router) {
|
||||
php81Controller := php81.NewPhp81Controller()
|
||||
@@ -203,8 +203,8 @@ func Plugin() {
|
||||
route.Post("clearErrorLog", php81Controller.ClearErrorLog)
|
||||
route.Post("clearSlowLog", php81Controller.ClearSlowLog)
|
||||
route.Get("extensions", php81Controller.GetExtensionList)
|
||||
route.Post("installExtension", php81Controller.InstallExtension)
|
||||
route.Post("uninstallExtension", php81Controller.UninstallExtension)
|
||||
route.Post("extensions", php81Controller.InstallExtension)
|
||||
route.Delete("extensions", php81Controller.UninstallExtension)
|
||||
})
|
||||
facades.Route().Prefix("api/plugins/php82").Middleware(middleware.Jwt()).Group(func(route route.Router) {
|
||||
php82Controller := php82.NewPhp82Controller()
|
||||
@@ -221,8 +221,8 @@ func Plugin() {
|
||||
route.Post("clearErrorLog", php82Controller.ClearErrorLog)
|
||||
route.Post("clearSlowLog", php82Controller.ClearSlowLog)
|
||||
route.Get("extensions", php82Controller.GetExtensionList)
|
||||
route.Post("installExtension", php82Controller.InstallExtension)
|
||||
route.Post("uninstallExtension", php82Controller.UninstallExtension)
|
||||
route.Post("extensions", php82Controller.InstallExtension)
|
||||
route.Delete("extensions", php82Controller.UninstallExtension)
|
||||
})
|
||||
facades.Route().Prefix("api/plugins/phpmyadmin").Middleware(middleware.Jwt()).Group(func(route route.Router) {
|
||||
phpMyAdminController := phpmyadmin.NewPhpMyAdminController()
|
||||
|
||||
Reference in New Issue
Block a user