organization

This commit is contained in:
skiffer-git 2022-04-18 18:11:07 +08:00 committed by Xinwei Xiong(cubxxw-openim)
parent 0392d9e900
commit dbf233d30b

View File

@ -73,7 +73,7 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.CreateDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.CreateDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
department := db.Department{} department := db.Department{}
@ -105,7 +105,7 @@ func (s *organizationServer) UpdateDepartment(ctx context.Context, req *rpc.Upda
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.UpdateDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.UpdateDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
department := db.Department{} department := db.Department{}
@ -148,7 +148,7 @@ func (s *organizationServer) DeleteDepartment(ctx context.Context, req *rpc.Dele
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.DeleteDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.DeleteDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
err := imdb.DeleteDepartment(req.DepartmentID) err := imdb.DeleteDepartment(req.DepartmentID)
if err != nil { if err != nil {
@ -167,7 +167,7 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.CreateOrganizationUserResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.CreateOrganizationUserResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
organizationUser := db.OrganizationUser{} organizationUser := db.OrganizationUser{}
utils.CopyStructFields(&organizationUser, req.OrganizationUser) utils.CopyStructFields(&organizationUser, req.OrganizationUser)
@ -285,7 +285,7 @@ func (s *organizationServer) UpdateUserInDepartment(ctx context.Context, req *rp
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.UpdateUserInDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.UpdateUserInDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
departmentMember := &db.DepartmentMember{} departmentMember := &db.DepartmentMember{}
utils.CopyStructFields(departmentMember, req.DepartmentMember) utils.CopyStructFields(departmentMember, req.DepartmentMember)
@ -306,7 +306,7 @@ func (s *organizationServer) DeleteUserInDepartment(ctx context.Context, req *rp
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.DeleteUserInDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.DeleteUserInDepartmentResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
err := imdb.DeleteUserInDepartment(req.DepartmentID, req.UserID) err := imdb.DeleteUserInDepartment(req.DepartmentID, req.UserID)
@ -326,7 +326,7 @@ func (s *organizationServer) DeleteOrganizationUser(ctx context.Context, req *rp
if !token_verify.IsManagerUserID(req.OpUserID) { if !token_verify.IsManagerUserID(req.OpUserID) {
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager" errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg) log.Error(req.OperationID, errMsg)
return &rpc.DeleteOrganizationUserResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil return &rpc.DeleteOrganizationUserResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
err := imdb.DeleteOrganizationUser(req.UserID) err := imdb.DeleteOrganizationUser(req.UserID)
if err != nil { if err != nil {
@ -344,9 +344,9 @@ func (s *organizationServer) GetDepartmentMember(ctx context.Context, req *rpc.G
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
err, departmentMemberList := imdb.GetDepartmentMemberList(req.DepartmentID) err, departmentMemberList := imdb.GetDepartmentMemberList(req.DepartmentID)
if err != nil { if err != nil {
errMsg := req.OperationID + " " + "GetDepartmentMemberList failed " + err.Error() errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
log.Error(req.OperationID, errMsg, req.DepartmentID) log.Error(req.OperationID, errMsg)
return &rpc.GetDepartmentMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil return &rpc.GetDepartmentMemberResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}, nil
} }
log.Debug(req.OperationID, "GetDepartmentMemberList ", departmentMemberList) log.Debug(req.OperationID, "GetDepartmentMemberList ", departmentMemberList)