mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
!84 fix: 修复数据库备份与恢复问题
* refactor dbScheduler * fix: 按团队名称检索团队 * feat: 创建数据库资源时支持全选数据库 * refactor dbScheduler * fix: 修复数据库备份与恢复问题
This commit is contained in:
@@ -22,10 +22,10 @@ type Repo[T model.ModelI] interface {
|
||||
InsertWithDb(ctx context.Context, db *gorm.DB, e T) error
|
||||
|
||||
// 批量新增实体
|
||||
BatchInsert(ctx context.Context, models any) error
|
||||
BatchInsert(ctx context.Context, models []T) error
|
||||
|
||||
// 使用指定gorm db执行,主要用于事务执行
|
||||
BatchInsertWithDb(ctx context.Context, db *gorm.DB, models any) error
|
||||
BatchInsertWithDb(ctx context.Context, db *gorm.DB, models []T) error
|
||||
|
||||
// 根据实体id更新实体信息
|
||||
UpdateById(ctx context.Context, e T, columns ...string) error
|
||||
@@ -93,19 +93,19 @@ func (br *RepoImpl[T]) InsertWithDb(ctx context.Context, db *gorm.DB, e T) error
|
||||
return gormx.InsertWithDb(db, br.fillBaseInfo(ctx, e))
|
||||
}
|
||||
|
||||
func (br *RepoImpl[T]) BatchInsert(ctx context.Context, es any) error {
|
||||
func (br *RepoImpl[T]) BatchInsert(ctx context.Context, es []T) error {
|
||||
if db := contextx.GetDb(ctx); db != nil {
|
||||
return br.BatchInsertWithDb(ctx, db, es)
|
||||
}
|
||||
for _, e := range es.([]T) {
|
||||
for _, e := range es {
|
||||
br.fillBaseInfo(ctx, e)
|
||||
}
|
||||
return gormx.BatchInsert[T](es)
|
||||
}
|
||||
|
||||
// 使用指定gorm db执行,主要用于事务执行
|
||||
func (br *RepoImpl[T]) BatchInsertWithDb(ctx context.Context, db *gorm.DB, es any) error {
|
||||
for _, e := range es.([]T) {
|
||||
func (br *RepoImpl[T]) BatchInsertWithDb(ctx context.Context, db *gorm.DB, es []T) error {
|
||||
for _, e := range es {
|
||||
br.fillBaseInfo(ctx, e)
|
||||
}
|
||||
return gormx.BatchInsertWithDb[T](db, es)
|
||||
|
||||
Reference in New Issue
Block a user