mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 04:22:33 +08:00
feat: 从数据库读取备份记录
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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{},
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user