|
|
@@ -1,9 +1,9 @@
|
|
|
package com.cyksj.service.authorization.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.cyksj.common.EnvCommonService;
|
|
|
import com.cyksj.common.util.Codec;
|
|
|
import com.cyksj.config.WeChatConfig;
|
|
|
-import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
|
|
|
import com.cyksj.enums.WeChatAuthRedirectUrl;
|
|
|
import com.cyksj.model.dto.JsSdkTicket;
|
|
|
import com.cyksj.service.authorization.AuthorizationService;
|
|
|
@@ -16,6 +16,7 @@ import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -32,13 +33,14 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|
|
|
|
|
private final WeChatConfig weChatConfig;
|
|
|
|
|
|
- private final WxOpenPlatYHLXLoginConfig wxOpenPlatYHLXLoginConfig;
|
|
|
+ private final EnvCommonService envCommonService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public String createUrl(String url, String state, String authType) throws MalformedURLException {
|
|
|
- String domain = gerUrlDomain(url);
|
|
|
- return weChatService.createUrl(state, (domain != null ? domain : weChatConfig.getDomain()) + WeChatAuthRedirectUrl.get(authType).getUrl()
|
|
|
+ String preUrl = Optional.ofNullable(gerUrlDomain(url)).orElse(weChatConfig.getDomain());
|
|
|
+ log.info("回调url:{}", preUrl);
|
|
|
+ return weChatService.createUrl(state, preUrl + WeChatAuthRedirectUrl.get(authType).getUrl()
|
|
|
, weChatConfig.getAppid(), WeChatAuthRedirectUrl.get(authType).getScope());
|
|
|
}
|
|
|
@Override
|
|
|
@@ -69,15 +71,22 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|
|
return weChatService.createWxAuthLoginUrl(state, appId, URLEncoder.encode(redirectUrl, StandardCharsets.UTF_8));
|
|
|
}
|
|
|
|
|
|
- public static String gerUrlDomain(String url) {
|
|
|
+ public String gerUrlDomain(String url) {
|
|
|
try {
|
|
|
- if (StrUtil.isNotBlank(url) && !url.contains("nf.video")) {
|
|
|
+ if (StrUtil.isNotBlank(url) && !url.contains("https://nf.video")) {
|
|
|
if (!url.contains("http")) {
|
|
|
url = "https://" + url;
|
|
|
}
|
|
|
URL questUrl = new URL(url);
|
|
|
String domain = questUrl.getAuthority();
|
|
|
- return "https://" + domain + "/";
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append("https://").append(domain).append("/");
|
|
|
+ if (envCommonService.isPreEnv()) {
|
|
|
+ sb.append("8082/api/");
|
|
|
+ } else {
|
|
|
+ sb.append("8081/api/");
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
}
|
|
|
} catch (MalformedURLException e) {
|
|
|
}
|