mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-10 09:50:25 +08:00
重构数据库备份与恢复模块 (#80)
* 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 文件,忽略数据库备份目录和数据库程序目录
This commit is contained in:
@@ -11,6 +11,9 @@ import (
|
||||
// 基础repo接口
|
||||
type Repo[T model.ModelI] interface {
|
||||
|
||||
// GetModel 获取表的模型实例
|
||||
GetModel() T
|
||||
|
||||
// 新增一个实体
|
||||
Insert(ctx context.Context, e T) error
|
||||
|
||||
@@ -24,10 +27,10 @@ type Repo[T model.ModelI] interface {
|
||||
BatchInsertWithDb(ctx context.Context, db *gorm.DB, es []T) error
|
||||
|
||||
// 根据实体id更新实体信息
|
||||
UpdateById(ctx context.Context, e T) error
|
||||
UpdateById(ctx context.Context, e T, columns ...string) error
|
||||
|
||||
// 使用指定gorm db执行,主要用于事务执行
|
||||
UpdateByIdWithDb(ctx context.Context, db *gorm.DB, e T) error
|
||||
UpdateByIdWithDb(ctx context.Context, db *gorm.DB, e T, columns ...string) error
|
||||
|
||||
// 根据实体主键删除实体
|
||||
DeleteById(ctx context.Context, id uint64) error
|
||||
@@ -101,16 +104,16 @@ func (br *RepoImpl[T]) BatchInsertWithDb(ctx context.Context, db *gorm.DB, es []
|
||||
return gormx.BatchInsertWithDb(db, es)
|
||||
}
|
||||
|
||||
func (br *RepoImpl[T]) UpdateById(ctx context.Context, e T) error {
|
||||
func (br *RepoImpl[T]) UpdateById(ctx context.Context, e T, columns ...string) error {
|
||||
if db := contextx.GetDb(ctx); db != nil {
|
||||
return br.UpdateByIdWithDb(ctx, db, e)
|
||||
return br.UpdateByIdWithDb(ctx, db, e, columns...)
|
||||
}
|
||||
|
||||
return gormx.UpdateById(br.setBaseInfo(ctx, e))
|
||||
return gormx.UpdateById(br.setBaseInfo(ctx, e), columns...)
|
||||
}
|
||||
|
||||
func (br *RepoImpl[T]) UpdateByIdWithDb(ctx context.Context, db *gorm.DB, e T) error {
|
||||
return gormx.UpdateByIdWithDb(db, br.setBaseInfo(ctx, e))
|
||||
func (br *RepoImpl[T]) UpdateByIdWithDb(ctx context.Context, db *gorm.DB, e T, columns ...string) error {
|
||||
return gormx.UpdateByIdWithDb(db, br.setBaseInfo(ctx, e), columns...)
|
||||
}
|
||||
|
||||
func (br *RepoImpl[T]) Updates(cond any, udpateFields map[string]any) error {
|
||||
|
||||
Reference in New Issue
Block a user