Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix🐛: declaration of new local variable causes transactions to be ign… #814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/admin/service/sys_dept.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions app/admin/service/sys_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down