diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index 5519135b3..5ed04bf7e 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -347,15 +347,15 @@ type RevokeElem struct { RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"` } type OANotificationElem struct { - NotificationName string `mapstructure:"notificationName" validate:"required"` - NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"` - NotificationType int32 `mapstructure:"notificationType" validate:"required"` - Text string `mapstructure:"text" validate:"required"` - Url string `mapstructure:"url"` - MixType int32 `mapstructure:"mixType"` - PictureElem PictureElem `mapstructure:"pictureElem"` - SoundElem SoundElem `mapstructure:"soundElem"` - VideoElem VideoElem `mapstructure:"videoElem"` - FileElem FileElem `mapstructure:"fileElem"` - Ex string `mapstructure:"ex"` + NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"` + NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL" validate:"required"` + NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"` + Text string `mapstructure:"text" json:"text" validate:"required"` + Url string `mapstructure:"url" json:"url"` + MixType int32 `mapstructure:"mixType" json:"mixType"` + PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"` + SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"` + VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"` + FileElem FileElem `mapstructure:"fileElem" json:"fileElem"` + Ex string `mapstructure:"ex" json:"ex"` } diff --git a/internal/demo/register/onboarding_process.go b/internal/demo/register/onboarding_process.go index 56be5bc78..a937fc3eb 100644 --- a/internal/demo/register/onboarding_process.go +++ b/internal/demo/register/onboarding_process.go @@ -5,6 +5,7 @@ import ( "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" + imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" groupRpc "Open_IM/pkg/proto/group" @@ -29,7 +30,12 @@ func onboardingProcess(operationID, userID, userName string) { if err := joinTestDepartment(operationID, userID, departmentID); err != nil { log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error()) } - + departmentID, err := imdb.GetRandomDepartmentID() + log.NewInfo(operationID, utils.GetSelfFuncName(), "random departmentID", departmentID) + if err != nil { + log.NewError(utils.GetSelfFuncName(), "GetRandomDepartmentID failed", err.Error()) + return + } groupIDList, err := GetDepartmentGroupIDList(operationID, departmentID) if err != nil { log.NewError(operationID, utils.GetSelfFuncName(), err.Error()) 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 43a144963..519b1f021 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 @@ -295,3 +295,13 @@ func GetDepartmentParentIDList(departmentID string) ([]string, error) { err = GetDepartmentParent(departmentID, dbConn, &parentIDList) 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 +}