Skip to content

Commit e4f33ce

Browse files
committed
feat: Update backup api
1 parent 5398819 commit e4f33ce

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

agent/init/migration/migrations/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
var AddTable = &gormigrate.Migration{
18-
ID: "20241009-add-table",
18+
ID: "20241226-add-table",
1919
Migrate: func(tx *gorm.DB) error {
2020
return tx.AutoMigrate(
2121
&model.AppDetail{},

core/app/service/backup.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ func (u *BackupService) GetLocalDir() (string, error) {
107107
}
108108

109109
func (u *BackupService) SearchWithPage(req dto.SearchPageWithType) (int64, interface{}, error) {
110-
count, accounts, err := backupRepo.Page(
111-
req.Page,
112-
req.PageSize,
113-
repo.WithByType(req.Type),
114-
repo.WithByName(req.Info),
115-
repo.WithOrderBy("created_at desc"),
116-
)
110+
options := []global.DBOption{repo.WithOrderBy("created_at desc")}
111+
if len(req.Type) != 0 {
112+
options = append(options, repo.WithByType(req.Type))
113+
}
114+
if len(req.Info) != 0 {
115+
options = append(options, repo.WithByType(req.Info))
116+
}
117+
count, accounts, err := backupRepo.Page(req.Page, req.PageSize, options...)
117118
if err != nil {
118119
return 0, nil, err
119120
}

frontend/src/api/modules/backup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export const listBackupOptions = () => {
1212
export const handleBackup = (params: Backup.Backup) => {
1313
return http.post(`/backups/backup`, params, TimeoutEnum.T_1H);
1414
};
15+
export const listBackupOptions = () => {
16+
return http.get<Array<Backup.BackupOption>>(`/backups/options`);
17+
};
1518
export const handleRecover = (params: Backup.Recover) => {
1619
return http.post(`/backups/recover`, params, TimeoutEnum.T_1D);
1720
};

0 commit comments

Comments
 (0)