Skip to content

Commit cb3fd49

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

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { Backup } from '../interface/backup';
66
import { TimeoutEnum } from '@/enums/http-enum';
77

88
// backup-agent
9-
export const listBackupOptions = () => {
10-
return http.get<Array<Backup.BackupOption>>(`/backups/options`);
11-
};
129
export const handleBackup = (params: Backup.Backup) => {
1310
return http.post(`/backups/backup`, params, TimeoutEnum.T_1H);
1411
};
12+
export const listBackupOptions = () => {
13+
return http.get<Array<Backup.BackupOption>>(`/backups/options`);
14+
};
1515
export const handleRecover = (params: Backup.Recover) => {
1616
return http.post(`/backups/recover`, params, TimeoutEnum.T_1D);
1717
};

0 commit comments

Comments
 (0)