作者 tangxvhui

bug 修复

... ... @@ -103,12 +103,23 @@ func UpdateDepartmentData(data ModuleDeparmentData) error {
return errors.New("获取部门数据失败")
}
departmentData.Name = data.Name
err = models.UpdateDepartmentById(departmentData, []string{"Name"})
o := orm.NewOrm()
o.Begin()
err = models.UpdateDepartmentById(departmentData, []string{"Name"}, o)
if err != nil {
o.Rollback()
e := fmt.Errorf("更新部门数据失败,err:%s", err)
log.Error(e.Error())
return errors.New("更新部门数据失败")
}
//更新部门管理员
err = models.ChangeDepartmentCharge(data.Id, departmentData.Id, data.Charge, o)
if err != nil {
o.Rollback()
log.Error("变更公司管理员失败,err:%s", err)
return errors.New("变更公司管理员失败")
}
o.Commit()
var (
newParentDepart *models.Department
)
... ... @@ -124,6 +135,7 @@ func UpdateDepartmentData(data ModuleDeparmentData) error {
log.Error("获取父级数据失败,business_admin_id=%d,err:%s", data.ParentId, err)
}
}
if departmentData.ParentId != newParentDepart.Id {
//更新父级
err = departmentRelationUpdate(*departmentData, *newParentDepart)
... ...