Merge branch 'v1-fixbug' into dev

# Conflicts:
#	models/dept.go
This commit is contained in:
zhangwenjian
2020-07-01 22:57:44 +08:00
2 changed files with 78 additions and 3 deletions
+7 -1
View File
@@ -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
}