refactor(game): 重构游戏 API 地址来源
- 替换 ISysConfigService 为 IPlatformService - 使用 GamePlatforms枚举替代硬编码的平台名称 - 优化地址获取逻辑,提高代码复用性 - 删除未使用的 Random 类导入 -调整代码格式,提高可读性main-meitian
parent
f1aa9d26e7
commit
ad40fc712d
|
@ -3,8 +3,8 @@ package com.ff.game.api.ae.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -20,12 +20,12 @@ import javax.annotation.Resource;
|
||||||
public class MyAEAddressSource implements AddressSource {
|
public class MyAEAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.AE_API_BASE_URL);
|
String apiBaseUrl = platformService.get(GamePlatforms.AE.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "");
|
return new ForestAddress("https", apiBaseUrl, 443, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.dg.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -20,12 +20,12 @@ import javax.annotation.Resource;
|
||||||
public class MyDGAddressSource implements AddressSource {
|
public class MyDGAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.DG_API_BASE_URL);
|
String apiBaseUrl = platformService.get(GamePlatforms.DG.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("http", apiBaseUrl, 80, "");
|
return new ForestAddress("http", apiBaseUrl, 80, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.fc.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -13,12 +13,13 @@ import javax.annotation.Resource;
|
||||||
public class MyFCAddressSource implements AddressSource {
|
public class MyFCAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.FC_API_BASE_URL);
|
String apiBaseUrl = platformService.get(GamePlatforms.FC.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "");
|
return new ForestAddress("https", apiBaseUrl, 443, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,11 @@ package com.ff.game.api.jili.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,12 +20,12 @@ import java.util.Random;
|
||||||
public class MyJILIAddressSource implements AddressSource {
|
public class MyJILIAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.JILI_API_BASE_URL);
|
String apiBaseUrl = platformService.get(GamePlatforms.FC.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "api1");
|
return new ForestAddress("https", apiBaseUrl, 443, "api1");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.km.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -20,12 +20,12 @@ import javax.annotation.Resource;
|
||||||
public class MyKMAddressSource implements AddressSource {
|
public class MyKMAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.KM_API_BASE_URL_LOGIN);
|
String apiBaseUrl = platformService.get(GamePlatforms.KM.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.ng.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -13,12 +13,14 @@ import javax.annotation.Resource;
|
||||||
public class MyNGAddressSource implements AddressSource {
|
public class MyNGAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.NG_API_BASE_URL);
|
//String apiBaseUrl = configService.selectConfigByKey(Constants.NG_API_BASE_URL);
|
||||||
|
String apiBaseUrl = platformService.get(GamePlatforms.PG.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.pgx.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -20,12 +20,13 @@ import javax.annotation.Resource;
|
||||||
public class MyPGXAddressSource implements AddressSource {
|
public class MyPGXAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.PGX_API_BASE_URL);
|
// String apiBaseUrl = configService.selectConfigByKey(Constants.PGX_API_BASE_URL);
|
||||||
|
String apiBaseUrl = platformService.get(GamePlatforms.PGX.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("http", apiBaseUrl, 80, "");
|
return new ForestAddress("http", apiBaseUrl, 80, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.sa.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -20,12 +20,14 @@ import javax.annotation.Resource;
|
||||||
public class MySAAddressSource implements AddressSource {
|
public class MySAAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.SA_API_BASE_URL);
|
// String apiBaseUrl = configService.selectConfigByKey(Constants.SA_API_BASE_URL);
|
||||||
|
String apiBaseUrl = platformService.get(GamePlatforms.SA.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package com.ff.game.api.xk.address;
|
||||||
import com.dtflys.forest.callback.AddressSource;
|
import com.dtflys.forest.callback.AddressSource;
|
||||||
import com.dtflys.forest.http.ForestAddress;
|
import com.dtflys.forest.http.ForestAddress;
|
||||||
import com.dtflys.forest.http.ForestRequest;
|
import com.dtflys.forest.http.ForestRequest;
|
||||||
import com.ff.base.constant.Constants;
|
import com.ff.base.enums.GamePlatforms;
|
||||||
import com.ff.base.system.service.ISysConfigService;
|
import com.ff.game.service.IPlatformService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -20,12 +20,13 @@ import javax.annotation.Resource;
|
||||||
public class MyXKAddressSource implements AddressSource {
|
public class MyXKAddressSource implements AddressSource {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysConfigService configService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForestAddress getAddress(ForestRequest request) {
|
public ForestAddress getAddress(ForestRequest request) {
|
||||||
String apiBaseUrl = configService.selectConfigByKey(Constants.XK_API_BASE_URL);
|
// String apiBaseUrl = configService.selectConfigByKey(Constants.XK_API_BASE_URL);
|
||||||
|
String apiBaseUrl = platformService.get(GamePlatforms.XK.getCode())
|
||||||
|
.getUrlInfo().getUrl();
|
||||||
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
return new ForestAddress("https", apiBaseUrl, 443, "api");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue