2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 04:22:33 +08:00

feat: 从数据库读取备份记录

This commit is contained in:
2026-01-19 23:50:04 +08:00
parent 046105a542
commit 5c6892c7f5
3 changed files with 22 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import "mime/multipart"
type BackupList struct {
Type string `uri:"type" form:"type" validate:"required|in:path,website,mysql,postgres,redis,panel"`
Paginate
}
type BackupCreate struct {

View File

@@ -59,4 +59,19 @@ func init() {
return tx.Migrator().DropTable(&biz.Project{})
},
})
Migrations = append(Migrations, &gormigrate.Migration{
ID: "20260120-add-backup",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(
&biz.Backup{},
&biz.BackupAccount{},
)
},
Rollback: func(tx *gorm.DB) error {
return tx.Migrator().DropTable(
&biz.Backup{},
&biz.BackupAccount{},
)
},
})
}

View File

@@ -34,12 +34,15 @@ func (s *BackupService) List(w http.ResponseWriter, r *http.Request) {
return
}
list, _ := s.backupRepo.List(biz.BackupType(req.Type))
paged, total := Paginate(r, list)
list, total, err := s.backupRepo.List(req.Page, req.Limit, biz.BackupType(req.Type))
if err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
}
Success(w, chix.M{
"total": total,
"items": paged,
"items": list,
})
}