From b3f924c08187afa1271551d7f45e822a4a3ac9ca Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 17 Jun 2022 10:36:46 +0800 Subject: [PATCH] fix bug --- pkg/common/db/mysql_model/im_mysql_model/organization_model.go | 2 +- 1 file changed, 1 insertion(+), 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 733dfad97..0c472fbcb 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 @@ -287,6 +287,6 @@ func GetRandomDepartmentID() (string, error) { return "", err } department := &db.Department{} - err = dbConn.Model(department).Where("related_group_id != ? AND parent_id != ?", "", "").Take(department).Error + err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ?", "").First(department).Error return department.DepartmentID, err }