From 5c6892c7f549bef2a6e5ebc52cd55d8e94f8deca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 19 Jan 2026 23:50:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=8E=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=A4=87=E4=BB=BD=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/http/request/backup.go | 1 + internal/migration/v1.go | 15 +++++++++++++++ internal/service/backup.go | 9 ++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/internal/http/request/backup.go b/internal/http/request/backup.go index 30df5f8f..daf3ce53 100644 --- a/internal/http/request/backup.go +++ b/internal/http/request/backup.go @@ -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 { diff --git a/internal/migration/v1.go b/internal/migration/v1.go index 682cc12b..e76b4d9f 100644 --- a/internal/migration/v1.go +++ b/internal/migration/v1.go @@ -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{}, + ) + }, + }) } diff --git a/internal/service/backup.go b/internal/service/backup.go index 3cc2194a..27e8dcbd 100644 --- a/internal/service/backup.go +++ b/internal/service/backup.go @@ -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, }) }