pull/455/head
wangchuxiao 2 years ago committed by Xinwei Xiong(cubxxw-openim)
parent 4329cfc414
commit 3825653c49

@ -5,6 +5,8 @@ import (
"Open_IM/internal/rpc/msg" "Open_IM/internal/rpc/msg"
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
groupRpc "Open_IM/pkg/proto/group" groupRpc "Open_IM/pkg/proto/group"
@ -30,7 +32,11 @@ func onboardingProcess(operationID, userID, userName string) {
if err := joinTestDepartment(operationID, userID, departmentID); err != nil { if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
} }
departmentID, err := imdb.GetRandomDepartmentID()
if err != nil {
log.NewError(utils.GetSelfFuncName(), "GetRandomDepartmentID failed", err.Error())
return
}
groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID) groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID)
if err != nil { if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), err.Error()) log.NewError(operationID, utils.GetSelfFuncName(), err.Error())

@ -280,3 +280,13 @@ func GetDepartmentParentIDList(departmentID string) ([]string, error) {
err = GetDepartmentParent(departmentID, dbConn, &parentIDList) err = GetDepartmentParent(departmentID, dbConn, &parentIDList)
return parentIDList, err return parentIDList, err
} }
func GetRandomDepartmentID() (string, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return "", err
}
department := &db.Department{}
err = dbConn.Model(department).Where("related_group_id != ? AND parent_id != ?", "", "").Take(department).Error
return department.DepartmentID, err
}

Loading…
Cancel
Save