From c8bf95578c4a43a87f30df6eab2c8ad798de8888 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 9 Jun 2022 15:25:02 +0800 Subject: [PATCH] fix bug --- .../db/mysql_model/im_mysql_model/organization_model.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/common/db/mysql_model/im_mysql_model/organization_model.go b/pkg/common/db/mysql_model/im_mysql_model/organization_model.go index f0539edbd..baf6acc8e 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/organization_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/organization_model.go @@ -265,7 +265,9 @@ func getDepartmentParent(departmentID string, dbConn *gorm.DB) (*db.Department, if err != nil { return nil, utils.Wrap(err, "") } - err = dbConn.Model(&parentDepartment).Where("department_id = ?", department.ParentID).Find(&parentDepartment).Error + if department.ParentID != "" { + err = dbConn.Model(&parentDepartment).Where("department_id = ?", department.ParentID).Find(&parentDepartment).Error + } return &parentDepartment, utils.Wrap(err, "") }