From b954a2f092509f6afda3b410d96546de3cdd8c7e Mon Sep 17 00:00:00 2001 From: keemozhang Date: Thu, 5 Sep 2024 15:46:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=90=9B:=20declaration=20of=20new=20loc?= =?UTF-8?q?al=20variable=20causes=20transactions=20to=20be=20ignored?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/sys_dept.go | 2 +- app/admin/service/sys_role.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/admin/service/sys_dept.go b/app/admin/service/sys_dept.go index cffd730ac..f1d988b30 100644 --- a/app/admin/service/sys_dept.go +++ b/app/admin/service/sys_dept.go @@ -84,7 +84,7 @@ func (e *SysDept) Insert(c *dto.SysDeptInsertReq) error { } var mp = map[string]string{} mp["dept_path"] = deptPath - if err := tx.Model(&data).Update("dept_path", deptPath).Error; err != nil { + if err = tx.Model(&data).Update("dept_path", deptPath).Error; err != nil { e.Log.Errorf("db error:%s", err) return err } diff --git a/app/admin/service/sys_role.go b/app/admin/service/sys_role.go index f1fee74be..83b2c4690 100644 --- a/app/admin/service/sys_role.go +++ b/app/admin/service/sys_role.go @@ -75,7 +75,7 @@ func (e *SysRole) Insert(c *dto.SysRoleInsertReq, cb *casbin.SyncedEnforcer) err c.Generate(&data) tx := e.Orm if config.DatabaseConfig.Driver != "sqlite3" { - tx := e.Orm.Begin() + tx = e.Orm.Begin() defer func() { if err != nil { tx.Rollback() @@ -132,7 +132,7 @@ func (e *SysRole) Update(c *dto.SysRoleUpdateReq, cb *casbin.SyncedEnforcer) err var err error tx := e.Orm if config.DatabaseConfig.Driver != "sqlite3" { - tx := e.Orm.Begin() + tx = e.Orm.Begin() defer func() { if err != nil { tx.Rollback() @@ -197,7 +197,7 @@ func (e *SysRole) Remove(c *dto.SysRoleDeleteReq, cb *casbin.SyncedEnforcer) err var err error tx := e.Orm if config.DatabaseConfig.Driver != "sqlite3" { - tx := e.Orm.Begin() + tx = e.Orm.Begin() defer func() { if err != nil { tx.Rollback() @@ -244,7 +244,7 @@ func (e *SysRole) UpdateDataScope(c *dto.RoleDataScopeReq) *SysRole { var err error tx := e.Orm if config.DatabaseConfig.Driver != "sqlite3" { - tx := e.Orm.Begin() + tx = e.Orm.Begin() defer func() { if err != nil { tx.Rollback() @@ -285,7 +285,7 @@ func (e *SysRole) UpdateStatus(c *dto.UpdateStatusReq) error { var err error tx := e.Orm if config.DatabaseConfig.Driver != "sqlite3" { - tx := e.Orm.Begin() + tx = e.Orm.Begin() defer func() { if err != nil { tx.Rollback()