Commit eb70db9d authored by xuxin's avatar xuxin

Merge remote-tracking branch 'origin/staging' into staging

parents e3d418f5 d591cf5f
...@@ -42,7 +42,7 @@ public class AccountDto { ...@@ -42,7 +42,7 @@ public class AccountDto {
private List<String> whiteList = new ArrayList<>(); private List<String> whiteList = new ArrayList<>();
private List<String> userWhiteList = new ArrayList<>(); private List<String> ownWhiteList = new ArrayList<>();
private ShopSummary shopSummary; private ShopSummary shopSummary;
...@@ -70,8 +70,11 @@ public class AccountDto { ...@@ -70,8 +70,11 @@ public class AccountDto {
this.setParent(account.getParent()); this.setParent(account.getParent());
this.setToken(account.getToken()); this.setToken(account.getToken());
this.setPermission(account.getPermission()); this.setPermission(account.getPermission());
this.setWhiteList(account.getWhiteList()); List<String> whiteList = account.getWhiteList();
this.setUserWhiteList(account.getWhiteList()); this.setWhiteList(whiteList);
whiteList.add("google.com/recaptcha");
whiteList.add("google.com/js");
this.setOwnWhiteList(whiteList);
this.setQueryIpUrlList(account.getQueryIpUrlList()); this.setQueryIpUrlList(account.getQueryIpUrlList());
if (account.getPromotion() != null) { if (account.getPromotion() != null) {
this.setPromotion(account.getPromotion()); this.setPromotion(account.getPromotion());
...@@ -260,11 +263,11 @@ public class AccountDto { ...@@ -260,11 +263,11 @@ public class AccountDto {
this.promotionCode = promotionCode; this.promotionCode = promotionCode;
} }
public List<String> getUserWhiteList() { public List<String> getOwnWhiteList() {
return userWhiteList; return ownWhiteList;
} }
public void setUserWhiteList(List<String> userWhiteList) { public void setOwnWhiteList(List<String> ownWhiteList) {
this.userWhiteList = userWhiteList; this.ownWhiteList = ownWhiteList;
} }
} }
...@@ -273,6 +273,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -273,6 +273,7 @@ public class IpResourceServiceImpl implements IpResourceService {
// 只要 申请的 ip 地域不是在 大陆,则一定会执行下面 if 中的代码块 // 只要 申请的 ip 地域不是在 大陆,则一定会执行下面 if 中的代码块
boolean condition1 = StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion()); boolean condition1 = StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion());
boolean condition2 = ipResourceRequestDto.getVendor().equals("own") && ipResource.isSpecialLine(); boolean condition2 = ipResourceRequestDto.getVendor().equals("own") && ipResource.isSpecialLine();
if (condition1 || condition2) { if (condition1 || condition2) {
ipResource.setProxyUsername(ipResource.getAddr()); ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12)); ipResource.setProxyPassword(genRandom(3, 12));
...@@ -639,9 +640,6 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -639,9 +640,6 @@ public class IpResourceServiceImpl implements IpResourceService {
return ipOperationResultDto; return ipOperationResultDto;
} }
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override @Override
public IpPageResultDto getIpList(String username, int groupType, int page, int amount, IpFilterDto ipFilterDto) { public IpPageResultDto getIpList(String username, int groupType, int page, int amount, IpFilterDto ipFilterDto) {
// 获取当前用户的账户 // 获取当前用户的账户
...@@ -711,10 +709,14 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -711,10 +709,14 @@ public class IpResourceServiceImpl implements IpResourceService {
} }
// 2. 如果 ip 资源的 status 为 6(未分配) 或者 ( ip资源为专线 且 purchasedTime(购买IP的时间) 在 14 分钟内) // 2. 如果 ip 资源的 status 为 6(未分配) 或者 ( ip资源为专线 且 purchasedTime(购买IP的时间) 在 14 分钟内)
if (x.getStatus() == 6 || (x.isSpecialLine() && x.getPurchasedTime() > (Instant.now().minusSeconds(14 * 60).toEpochMilli()))) { if (x.getStatus() == 6) {
x.setStatus(3); x.setStatus(3);
} }
if(x.isSpecialLine() && x.getStatus() == 0 && x.getPurchasedTime() > (Instant.now().minusSeconds(14 * 60).toEpochMilli())) {
x.setSpecialLine(false);
}
// 3. 如果 ip 资源的 status 为 3(正在分配) // 3. 如果 ip 资源的 status 为 3(正在分配)
if (x.getStatus() == 3) { if (x.getStatus() == 3) {
x.setAddr(""); x.setAddr("");
...@@ -826,9 +828,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -826,9 +828,7 @@ public class IpResourceServiceImpl implements IpResourceService {
return false; return false;
} }
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override @Override
public IpResourceDto queryIp(String username, IpResourceRequestDto ipResourceRequestDto) { public IpResourceDto queryIp(String username, IpResourceRequestDto ipResourceRequestDto) {
Account account = accountRepository.findByName(username).orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST)); Account account = accountRepository.findByName(username).orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
......
...@@ -363,6 +363,13 @@ public class ShopServiceImpl implements ShopService { ...@@ -363,6 +363,13 @@ public class ShopServiceImpl implements ShopService {
} }
} }
public static List<String> region = Arrays.asList(
"asiapa", "hongkong", "japan", "s-korea", "us", "malaysia",
"yajiada", "singapore", "australia", "germany", "uk", "brazil",
"moscow", "canada", "france", "sweden", "s-korea", "india", "meast",
"brazil", "virginia", "ohio", "california", "oregon", "ireland", "london", "ireland"
);
@Override @Override
public ShopResultDto queryShop(String username, String shopId) { public ShopResultDto queryShop(String username, String shopId) {
// 1. 校验 账户、商铺、IP资源、usershop 信息 // 1. 校验 账户、商铺、IP资源、usershop 信息
...@@ -387,6 +394,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -387,6 +394,10 @@ public class ShopServiceImpl implements ShopService {
ipResourceDto = new IpResourceDto(ipResource, null, false); ipResourceDto = new IpResourceDto(ipResource, null, false);
} }
if(org.apache.commons.lang3.StringUtils.isNotBlank(ipResource.getRegion()) && region.contains(ipResource.getRegion())){
ipResourceDto.setSecondaryProxyPort("20020");
}
// 3. 封装 ShopResultDto 信息并返回 // 3. 封装 ShopResultDto 信息并返回
return ShopResultDto.of(shop, userShop.getGroupId(), ipResourceDto); return ShopResultDto.of(shop, userShop.getGroupId(), ipResourceDto);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment