mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-03 05:06:36 +08:00
feat: 实现数据库备份与恢复
This commit is contained in:
29
server/internal/db/api/form/db_restore.go
Normal file
29
server/internal/db/api/form/db_restore.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package form
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DbRestoreForm 数据库备份表单
|
||||
type DbRestoreForm struct {
|
||||
Id uint64 `json:"id"`
|
||||
DbName string `binding:"required" json:"dbName"` // 数据库名
|
||||
StartTime time.Time `binding:"required" json:"startTime"` // 开始时间: 2023-11-08 02:00:00
|
||||
PointInTime time.Time `json:"PointInTime"` // 指定时间
|
||||
DbBackupId uint64 `json:"dbBackupId"` // 数据库备份任务ID
|
||||
DbBackupHistoryId uint64 `json:"dbBackupHistoryId"` // 数据库备份历史ID
|
||||
DbBackupHistoryName string `json:"dbBackupHistoryName"` // 数据库备份历史名称
|
||||
Interval time.Duration `json:"-"` // 间隔时间: 为零表示单次执行,为正表示反复执行
|
||||
IntervalDay uint64 `json:"intervalDay"` // 间隔天数: 为零表示单次执行,为正表示反复执行
|
||||
Repeated bool `json:"repeated"` // 是否重复执行
|
||||
}
|
||||
|
||||
func (restore *DbRestoreForm) UnmarshalJSON(data []byte) error {
|
||||
type dbRestoreFormPtr *DbRestoreForm
|
||||
if err := json.Unmarshal(data, dbRestoreFormPtr(restore)); err != nil {
|
||||
return err
|
||||
}
|
||||
restore.Interval = time.Duration(restore.IntervalDay) * time.Hour * 24
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user