fix:修复上传
This commit is contained in:
@@ -52,6 +52,7 @@ func (m *FsResourceModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
||||
|
||||
// 事务
|
||||
func (m *FsResourceModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error {
|
||||
|
||||
tx := m.db.Table(m.name).WithContext(ctx).Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -60,6 +61,7 @@ func (m *FsResourceModel) Trans(ctx context.Context, fn func(ctx context.Context
|
||||
}()
|
||||
|
||||
if err := tx.Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -68,7 +70,13 @@ func (m *FsResourceModel) Trans(ctx context.Context, fn func(ctx context.Context
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit().Error
|
||||
err := tx.Commit().Error
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *FsResourceModel) TableName() string {
|
||||
|
||||
Reference in New Issue
Block a user