From 5664c34790afdb129f36a8adf862d69bb45c80e7 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 18 Apr 2022 18:02:11 +0800 Subject: [PATCH] organization --- internal/api/organization/organization.go | 2 +- internal/rpc/organization/organization.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/api/organization/organization.go b/internal/api/organization/organization.go index 240f3a848..9c6d53ace 100644 --- a/internal/api/organization/organization.go +++ b/internal/api/organization/organization.go @@ -433,7 +433,7 @@ func DeleteUserInDepartment(c *gin.Context) { return } - apiResp := api.GetDepartmentMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} + apiResp := api.DeleteUserInDepartmentResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}} log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp) c.JSON(http.StatusOK, apiResp) } diff --git a/internal/rpc/organization/organization.go b/internal/rpc/organization/organization.go index ae09d8915..b93fdc2b9 100644 --- a/internal/rpc/organization/organization.go +++ b/internal/rpc/organization/organization.go @@ -220,10 +220,17 @@ func (s *organizationServer) CreateDepartmentMember(ctx context.Context, req *rp return &rpc.CreateDepartmentMemberResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil } + err, _ := imdb.GetOrganizationUser(req.DepartmentMember.UserID) + if err != nil { + errMsg := req.OperationID + "" + req.DepartmentMember.UserID + " is not exist" + log.Error(req.OperationID, errMsg) + return &rpc.CreateDepartmentMemberResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil + } + departmentMember := db.DepartmentMember{} utils.CopyStructFields(&departmentMember, req.DepartmentMember) log.Debug(req.OperationID, "src ", *req.DepartmentMember, "dst ", departmentMember) - err := imdb.CreateDepartmentMember(&departmentMember) + err = imdb.CreateDepartmentMember(&departmentMember) if err != nil { errMsg := req.OperationID + " " + "CreateDepartmentMember failed " + err.Error() log.Error(req.OperationID, errMsg, departmentMember)