线上地址转发去掉SP_SYNC_SERVER

master
anthonywj 2 years ago
parent f8740d4a0a
commit e70b41d58c

@ -308,10 +308,12 @@ public class SpsSyncDataController {
if (StrUtil.isNotEmpty(upperServerHost)) {
uri = upperServerHost + "/" + uri;
}
changeUri(uri);
JSONObject jsonObject = redirect(request, uri);
return jsonObject;
}
private JSONObject redirect(HttpServletRequest request, String uri) {
RestTemplate restTemplate = new RestTemplate();
HttpEntity<String> httpEntity = uriUtils.buildHeader(request);
@ -364,5 +366,15 @@ public class SpsSyncDataController {
FileUtils.SaveFileAs(content, fileName);
}
public String changeUri(String uri) {
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
}
return uri;
}
}

@ -31,6 +31,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.PushBuilder;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Date;
@ -76,10 +77,7 @@ public class SyncController {
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
uri = uri.replace("orderApi/", "");
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
changeUri(uri);
}
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
if (StrUtil.isNotEmpty(upperServerHost)) {
@ -97,9 +95,7 @@ public class SyncController {
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
uri = uri.replace("busOrderApi/", "");
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
changeUri(uri);
}
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
@ -119,6 +115,7 @@ public class SyncController {
if (StrUtil.isNotEmpty(upperServerHost)) {
uri = upperServerHost + "/" + uri;
}
changeUri(uri);
JSONObject jsonObject = redirect(request, uri, ConstantStatus.SYNC_BUS_TYPE, BasicProcessStatus.NEW_ALL_BUS);
return jsonObject;
}
@ -132,6 +129,7 @@ public class SyncController {
if (StrUtil.isNotEmpty(upperServerHost)) {
uri = upperServerHost + "/" + uri;
}
changeUri(uri);
JSONObject jsonObject = redirect(request, uri, ConstantStatus.SYNC_BASIC_DATA, BasicProcessStatus.NEW_ALL_DATA);
return jsonObject;
}
@ -144,11 +142,7 @@ public class SyncController {
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
uri = uri.replace("syncToSpms/", "");
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
changeUri(uri);
}
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
if (StrUtil.isNotEmpty(upperServerHost)) {
@ -165,9 +159,7 @@ public class SyncController {
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
uri = uri.replace("directToSpms/", "");
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
changeUri(uri);
}
String upperServerHost = systemParamConfigService.selectValueByParamKey("upper_server_ip");
if (StrUtil.isNotEmpty(upperServerHost)) {
@ -266,4 +258,14 @@ public class SyncController {
}
public String changeUri(String uri) {
String isTopService = systemParamConfigService.selectValueByParamKey("is_top_service");
if (StrUtil.isNotEmpty(isTopService) && isTopService.equals("1")) {
if (uri.contains("SP_SYNC_SERVER")) {
uri = uri.replace("SP_SYNC_SERVER/", "");
}
}
return uri;
}
}

Loading…
Cancel
Save