mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	* fix: 保存 LastResult 时截断字符串过长部分,以避免数据库报错 * refactor: 新增 entity.DbTaskBase 和 persistence.dbTaskBase, 用于实现数据库备份和恢复任务处理相关部分 * fix: aeskey变更后,解密密码出现数组越界访问错误 * fix: 时间属性为零值时,保存到 mysql 数据库报错 * refactor db.infrastructure.service.scheduler * feat: 实现立即备份功能 * refactor db.infrastructure.service.db_instance * refactor: 从数据库中获取数据库备份目录、mysql文件路径等配置信息 * fix: 数据库备份和恢复问题 * fix: 修改 .gitignore 文件,忽略数据库备份目录和数据库程序目录
		
			
				
	
	
		
			31 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package form
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"mayfly-go/pkg/utils/timex"
 | 
						|
	"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         timex.NullTime `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
 | 
						|
}
 |