コード例 #1
0
        private async Task <CustomerInfo> GetDDUserInfoAsync(string identityId)
        {
            CustomerInfo customer = null;
            var          token    = await _ddHelper.GetAccessTokenAsync();

            var user = await _ddHelper.GetUserInfoAsync(token, identityId);

            if (user.errcode == "0")
            {
                customer = new CustomerInfo
                {
                    Avatar     = user.avatar,
                    Name       = user.name,
                    IdentityId = user.userid,
                    From       = "钉钉用户",
                    Email      = user.email,
                    Mobile     = user.mobile,
                    Position   = user.position
                };
                var departmentId = user.department?.FirstOrDefault();
                if (string.IsNullOrEmpty(departmentId) == false)
                {
                    var depart = await _ddHelper.GetDepartmentInfoByIdAsync(token, departmentId);

                    if (depart != null)
                    {
                        customer.Department = depart.Name;
                    }
                }
            }
            return(customer);
        }
コード例 #2
0
        public async Task <IActionResult> GetUserInfo(string code, string token)
        {
            var _userid = await _ddHelper.GetUserIdAsync(token, code);

            var userInfo = await _ddHelper.GetUserInfoAsync(token, _userid);

            ResultModel.ResultInfo <object> result = new ResultModel.ResultInfo <object>();
            result.Data    = userInfo;
            result.Code    = ResultModel.ResultCode.Success;
            result.Message = "免登录,获取个人信息成功!";
            return(Ok(result));
        }