| | |
| | | * 构建二维码图片公开访问地址。 |
| | | */ |
| | | private String buildQrCodeImageUrl(String inviteCode) { |
| | | String landingBaseUrl = trimToNull(appShareProperties.getLandingBaseUrl()); |
| | | if (landingBaseUrl == null) { |
| | | throw new IllegalArgumentException("邀请下载页地址暂未配置"); |
| | | String qrcodeImageBaseUrl = trimToNull(appShareProperties.getQrcodeImageBaseUrl()); |
| | | if (qrcodeImageBaseUrl == null) { |
| | | throw new IllegalArgumentException("分享二维码图片地址暂未配置"); |
| | | } |
| | | int schemeIndex = landingBaseUrl.indexOf("://"); |
| | | if (schemeIndex < 0) { |
| | | throw new IllegalArgumentException("邀请下载页地址格式不正确"); |
| | | } |
| | | int hostEndIndex = landingBaseUrl.indexOf('/', schemeIndex + 3); |
| | | String origin = hostEndIndex >= 0 ? landingBaseUrl.substring(0, hostEndIndex) : landingBaseUrl; |
| | | String normalizedInviteCode = trimToNull(inviteCode); |
| | | if (!StringUtils.hasText(normalizedInviteCode)) { |
| | | throw new IllegalArgumentException("邀请码不能为空"); |
| | | } |
| | | return origin + "/api/open/app-share/qrcode-image?inviteCode=" + normalizedInviteCode; |
| | | String queryJoiner = qrcodeImageBaseUrl.contains("?") ? "&" : "?"; |
| | | return qrcodeImageBaseUrl + queryJoiner + "inviteCode=" + normalizedInviteCode; |
| | | } |
| | | |
| | | /** |