mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 02:04:09 +00:00
Merge branch 'v1-fixbug' into dev
# Conflicts: # models/dept.go
This commit is contained in:
+7
-1
@@ -205,6 +205,12 @@ func (e *Dept) Update(id int) (update Dept, err error) {
|
||||
|
||||
func (e *Dept) Delete(id int) (success bool, err error) {
|
||||
|
||||
user := SysUser{}
|
||||
user.DeptId = id
|
||||
userlist, err := user.GetList()
|
||||
tools.HasError(err, "", 500)
|
||||
tools.Assert(len(userlist) <= 0, "当前部门存在用户,不能删除!", 500)
|
||||
|
||||
tx := orm.Eloquent.Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -222,7 +228,7 @@ func (e *Dept) Delete(id int) (success bool, err error) {
|
||||
tx.Rollback()
|
||||
return
|
||||
}
|
||||
if err =tx.Commit().Error; err != nil {
|
||||
if err = tx.Commit().Error; err != nil {
|
||||
success = false
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user