예제 #1
0
        public async Task <Result <string> > Handle(PcAuthorizationCommand request, CancellationToken cancellationToken)
        {
            var getLinkInput = request.AuthType switch
            {
                ThirdPartyAuthType.OfficialAccounts or
                ThirdPartyAuthType.MiniProgram or
                ThirdPartyAuthType.All => new GetAuthorizationLinkInput(request.AuthType),
                ThirdPartyAuthType.SpecifyOnly => new GetAuthorizationLinkInput(request.BizId),
                _ => throw new WeChatAdApterException(nameof(request.AuthType), $"{nameof(PcAuthorizationCommandHandle)}")
            };

            var linkOutput = await _thirdPartyOauthService.GetAuthorizationLinkAsync(getLinkInput);

            return(new Result <string>
            {
                IsSucceeded = !string.IsNullOrWhiteSpace(linkOutput.Link),
                Data = linkOutput.Link
            });
        }
    }