From c3d3f0986ea4aa182d9859e02624f1f8e6a0e429 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 29 Aug 2022 14:34:07 +0800 Subject: [PATCH] join groups --- config/config.yaml | 1 + internal/demo/register/onboarding_process.go | 16 +++++++++------- pkg/common/config/config.go | 15 ++++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 5fbfe7492..b3d4813a4 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -750,6 +750,7 @@ demo: testDepartMentID: 001 imAPIURL: http://127.0.0.1:10002 onboardProcess: false # 是否开启注册流程 + createOrganizationUserAndJoinDepartment: false joinDepartmentIDList: [] # 用户注册进来默认加的部门ID列表 不填就随机 joinDepartmentGroups: false # 注册是否加部门群 oaNotification: false # 注册是否发送OA通知 diff --git a/internal/demo/register/onboarding_process.go b/internal/demo/register/onboarding_process.go index 0978b62b1..ea3426559 100644 --- a/internal/demo/register/onboarding_process.go +++ b/internal/demo/register/onboarding_process.go @@ -49,9 +49,7 @@ func OnboardingProcessRoutine() { func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, email string) { log.NewInfo(operationID, utils.GetSelfFuncName(), userName, userID, faceURL) - if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil { - log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error()) - } + var joinDepartmentIDList []string if len(config.Config.Demo.JoinDepartmentIDList) == 0 { departmentID, err := imdb.GetRandomDepartmentID() @@ -63,10 +61,14 @@ func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, emai } else { joinDepartmentIDList = config.Config.Demo.JoinDepartmentIDList } - - for _, departmentID := range joinDepartmentIDList { - if err := joinTestDepartment(operationID, userID, departmentID); err != nil { - log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error()) + if config.Config.Demo.CreateOrganizationUserAndJoinDepartment && len(joinDepartmentIDList) > 0 { + if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil { + log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error()) + } + for _, departmentID := range joinDepartmentIDList { + if err := joinTestDepartment(operationID, userID, departmentID); err != nil { + log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error()) + } } } diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index ba8b25fa2..359a6a848 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -501,13 +501,14 @@ type config struct { SmtpAddr string `yaml:"smtpAddr"` SmtpPort int `yaml:"smtpPort"` } - TestDepartMentID string `yaml:"testDepartMentID"` - ImAPIURL string `yaml:"imAPIURL"` - NeedInvitationCode bool `yaml:"needInvitationCode"` - OnboardProcess bool `yaml:"onboardProcess"` - JoinDepartmentIDList []string `yaml:"joinDepartmentIDList"` - JoinDepartmentGroups bool `yaml:"joinDepartmentGroups"` - OaNotification bool `yaml:"oaNotification"` + TestDepartMentID string `yaml:"testDepartMentID"` + ImAPIURL string `yaml:"imAPIURL"` + NeedInvitationCode bool `yaml:"needInvitationCode"` + OnboardProcess bool `yaml:"onboardProcess"` + JoinDepartmentIDList []string `yaml:"joinDepartmentIDList"` + JoinDepartmentGroups bool `yaml:"joinDepartmentGroups"` + OaNotification bool `yaml:"oaNotification"` + CreateOrganizationUserAndJoinDepartment bool `json:"createOrganizationUserAndJoinDepartment"` } Rtc struct { SignalTimeout string `yaml:"signalTimeout"`