mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-06 14:45:48 +08:00
!96 删除数据库备份和恢复历史
* feat: 删除数据库备份历史 * refactor dbScheduler * feat: 从数据库备份历史中恢复数据库 * feat: 删除数据库恢复历史记录 * refactor dbScheuler
This commit is contained in:
@@ -54,8 +54,7 @@ func (d *dbRestoreRepoImpl) ListToDo(jobs any) error {
|
||||
}
|
||||
|
||||
// GetPageList 分页获取数据库备份任务列表
|
||||
func (d *dbRestoreRepoImpl) GetPageList(condition *entity.DbJobQuery, pageParam *model.PageParam, toEntity any, _ ...string) (*model.PageResult[any], error) {
|
||||
d.GetModel()
|
||||
func (d *dbRestoreRepoImpl) GetPageList(condition *entity.DbRestoreQuery, pageParam *model.PageParam, toEntity any, _ ...string) (*model.PageResult[any], error) {
|
||||
qd := gormx.NewQuery(d.GetModel()).
|
||||
Eq("id", condition.Id).
|
||||
Eq0("db_instance_id", condition.DbInstanceId).
|
||||
@@ -65,6 +64,17 @@ func (d *dbRestoreRepoImpl) GetPageList(condition *entity.DbJobQuery, pageParam
|
||||
return gormx.PageQuery(qd, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (d *dbRestoreRepoImpl) GetEnabledRestores(toEntity any, backupHistoryId ...uint64) error {
|
||||
return global.Db.Model(d.GetModel()).
|
||||
Select("id", "db_backup_history_id", "last_status", "last_result", "last_time").
|
||||
Where("db_backup_history_id in ?", backupHistoryId).
|
||||
Where("enabled = true").
|
||||
Scopes(gormx.UndeleteScope).
|
||||
Order("id DESC").
|
||||
Find(toEntity).
|
||||
Error
|
||||
}
|
||||
|
||||
// AddJob 添加数据库任务
|
||||
func (d *dbRestoreRepoImpl) AddJob(ctx context.Context, jobs any) error {
|
||||
return addJob[*entity.DbRestore](ctx, d.dbJobBaseImpl, jobs)
|
||||
@@ -74,7 +84,12 @@ func (d *dbRestoreRepoImpl) UpdateEnabled(_ context.Context, jobId uint64, enabl
|
||||
cond := map[string]any{
|
||||
"id": jobId,
|
||||
}
|
||||
desc := "任务已禁用"
|
||||
if enabled {
|
||||
desc = "任务已启用"
|
||||
}
|
||||
return d.Updates(cond, map[string]any{
|
||||
"enabled": enabled,
|
||||
"enabled": enabled,
|
||||
"enabled_desc": desc,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user