Commit b2a47f58 authored by huangjiamin's avatar huangjiamin

用户白名单、KCP端口号

parent d3b6e6d7
...@@ -42,6 +42,8 @@ public class AccountDto { ...@@ -42,6 +42,8 @@ public class AccountDto {
private List<String> whiteList = new ArrayList<>(); private List<String> whiteList = new ArrayList<>();
private List<String> userWhiteList = new ArrayList<>();
private ShopSummary shopSummary; private ShopSummary shopSummary;
private IpSummary ipSummary; private IpSummary ipSummary;
...@@ -69,6 +71,7 @@ public class AccountDto { ...@@ -69,6 +71,7 @@ public class AccountDto {
this.setToken(account.getToken()); this.setToken(account.getToken());
this.setPermission(account.getPermission()); this.setPermission(account.getPermission());
this.setWhiteList(account.getWhiteList()); this.setWhiteList(account.getWhiteList());
this.setUserWhiteList(account.getWhiteList());
this.setQueryIpUrlList(account.getQueryIpUrlList()); this.setQueryIpUrlList(account.getQueryIpUrlList());
if (account.getPromotion() != null) { if (account.getPromotion() != null) {
this.setPromotion(account.getPromotion()); this.setPromotion(account.getPromotion());
...@@ -256,4 +259,12 @@ public class AccountDto { ...@@ -256,4 +259,12 @@ public class AccountDto {
public void setPromotionCode(String promotionCode) { public void setPromotionCode(String promotionCode) {
this.promotionCode = promotionCode; this.promotionCode = promotionCode;
} }
public List<String> getUserWhiteList() {
return userWhiteList;
}
public void setUserWhiteList(List<String> userWhiteList) {
this.userWhiteList = userWhiteList;
}
} }
...@@ -146,6 +146,11 @@ public class IpResource implements Serializable { ...@@ -146,6 +146,11 @@ public class IpResource implements Serializable {
*/ */
private int period; private int period;
/**
* KCP端口号
*/
private int secondaryProxyPort = -1;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
......
...@@ -35,6 +35,8 @@ public class IpResourceDto { ...@@ -35,6 +35,8 @@ public class IpResourceDto {
private String specialLineIp; private String specialLineIp;
private int secondaryProxyPort = -1;
public IpResourceDto() { public IpResourceDto() {
} }
...@@ -52,6 +54,7 @@ public class IpResourceDto { ...@@ -52,6 +54,7 @@ public class IpResourceDto {
this.password = ipResource.getPassword(); this.password = ipResource.getPassword();
this.protocol = ipResource.getProtocol(); this.protocol = ipResource.getProtocol();
this.specialLine = ipResource.isSpecialLine(); this.specialLine = ipResource.isSpecialLine();
this.secondaryProxyPort = ipResource.getSecondaryProxyPort();
if (CollectionUtils.isNotEmpty(shopDtos)) { if (CollectionUtils.isNotEmpty(shopDtos)) {
this.bindShops = shopDtos; this.bindShops = shopDtos;
this.bindShop = shopDtos.get(0); this.bindShop = shopDtos.get(0);
...@@ -63,7 +66,6 @@ public class IpResourceDto { ...@@ -63,7 +66,6 @@ public class IpResourceDto {
this.bindHistories = ipResource.getBindHistory(); this.bindHistories = ipResource.getBindHistory();
else else
this.bindHistories = new ArrayList<>(); this.bindHistories = new ArrayList<>();
} }
public IpResourceDto(IpResource ipResource, List<ShopDto> shopDtos, boolean useHistory, SpecialLine specialLine1) { public IpResourceDto(IpResource ipResource, List<ShopDto> shopDtos, boolean useHistory, SpecialLine specialLine1) {
...@@ -84,6 +86,7 @@ public class IpResourceDto { ...@@ -84,6 +86,7 @@ public class IpResourceDto {
this.proxyPort = specialLine1.getProxyPort(); this.proxyPort = specialLine1.getProxyPort();
this.proxyProtocol = specialLine1.getProxyProtocol(); this.proxyProtocol = specialLine1.getProxyProtocol();
this.specialLine = ipResource.isSpecialLine(); this.specialLine = ipResource.isSpecialLine();
this.secondaryProxyPort = ipResource.getSecondaryProxyPort();
if (CollectionUtils.isNotEmpty(shopDtos)) { if (CollectionUtils.isNotEmpty(shopDtos)) {
this.bindShops = shopDtos; this.bindShops = shopDtos;
this.bindShop = shopDtos.get(0); this.bindShop = shopDtos.get(0);
...@@ -265,4 +268,12 @@ public class IpResourceDto { ...@@ -265,4 +268,12 @@ public class IpResourceDto {
public void setBindShop(ShopDto bindShop) { public void setBindShop(ShopDto bindShop) {
this.bindShop = bindShop; this.bindShop = bindShop;
} }
public int getSecondaryProxyPort() {
return secondaryProxyPort;
}
public void setSecondaryProxyPort(int secondaryProxyPort) {
this.secondaryProxyPort = secondaryProxyPort;
}
} }
...@@ -175,9 +175,9 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -175,9 +175,9 @@ public class IpResourceServiceImpl implements IpResourceService {
Map<String, List<String>> priceList = ipOptionsRepository.findAll().get(0).getIpPlatForm(); Map<String, List<String>> priceList = ipOptionsRepository.findAll().get(0).getIpPlatForm();
List<String> vendorPrices = priceList.get(ipResourceRequestDto.getRegionCn()); List<String> vendorPrices = priceList.get(ipResourceRequestDto.getRegionCn());
String price = vendorPrices.stream() String price = vendorPrices.stream()
.filter(x -> Vendor.valueOf(ipResourceRequestDto.getVendor()).getValue().equals(x.substring(0, x.indexOf("-")))) .filter(x -> Vendor.valueOf(ipResourceRequestDto.getVendor()).getValue().equals(x.substring(0, x.indexOf("-"))))
.map(x -> x.substring(x.lastIndexOf("-") + 1)) .map(x -> x.substring(x.lastIndexOf("-") + 1))
.collect(Collectors.joining()); .collect(Collectors.joining());
newprice = "week".equals(ipResourceRequestDto.getUnit()) ? (Integer.valueOf(price) / 3) : Integer.valueOf(price); newprice = "week".equals(ipResourceRequestDto.getUnit()) ? (Integer.valueOf(price) / 3) : Integer.valueOf(price);
} }
...@@ -357,9 +357,9 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -357,9 +357,9 @@ public class IpResourceServiceImpl implements IpResourceService {
List<String> vendorPrices = ipPlatForm.get(ipResource.getRegionCn()); List<String> vendorPrices = ipPlatForm.get(ipResource.getRegionCn());
// 计算 ip 价格 // 计算 ip 价格
String price = vendorPrices.stream() String price = vendorPrices.stream()
.filter(vendorprice -> ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-")))) .filter(vendorprice -> ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-"))))
.map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1)) .map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1))
.collect(Collectors.joining()); .collect(Collectors.joining());
double newprice1 = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price) / 3) : Integer.valueOf(price); double newprice1 = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price) / 3) : Integer.valueOf(price);
// 封装 ip 的续费 信息 // 封装 ip 的续费 信息
...@@ -398,9 +398,9 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -398,9 +398,9 @@ public class IpResourceServiceImpl implements IpResourceService {
} }
String price = vendorPrices.stream() String price = vendorPrices.stream()
.filter(vendorprice -> ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-")))) .filter(vendorprice -> ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-"))))
.map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1)) .map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1))
.collect(Collectors.joining()); .collect(Collectors.joining());
double newprice1 = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price) / 3) : Integer.valueOf(price); double newprice1 = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price) / 3) : Integer.valueOf(price);
IpChargeRequestDto ipChargeRequestDto = buildIpChargeRequestDto(ipResourceRequestDto, 2, ipResourceRequestDto.getPayMethod()); IpChargeRequestDto ipChargeRequestDto = buildIpChargeRequestDto(ipResourceRequestDto, 2, ipResourceRequestDto.getPayMethod());
...@@ -409,10 +409,10 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -409,10 +409,10 @@ public class IpResourceServiceImpl implements IpResourceService {
if (ipResourceRequestDto.getUnit().equals("week")) { if (ipResourceRequestDto.getUnit().equals("week")) {
ipResource.setValidTime(Instant.ofEpochMilli(ipResource.getValidTime()).atZone(ZoneOffset.UTC) ipResource.setValidTime(Instant.ofEpochMilli(ipResource.getValidTime()).atZone(ZoneOffset.UTC)
.plusWeeks(finalPeriod).toInstant().toEpochMilli()); .plusWeeks(finalPeriod).toInstant().toEpochMilli());
} else { } else {
ipResource.setValidTime(Instant.ofEpochMilli(ipResource.getValidTime()).atZone(ZoneOffset.UTC) ipResource.setValidTime(Instant.ofEpochMilli(ipResource.getValidTime()).atZone(ZoneOffset.UTC)
.plusMonths(finalPeriod).toInstant().toEpochMilli()); .plusMonths(finalPeriod).toInstant().toEpochMilli());
} }
ipResourceRepository.save(ipResource); ipResourceRepository.save(ipResource);
ipOperationResultDto.getSuccessList().add(x); ipOperationResultDto.getSuccessList().add(x);
...@@ -639,6 +639,9 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -639,6 +639,9 @@ 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) {
// 获取当前用户的账户 // 获取当前用户的账户
...@@ -823,15 +826,19 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -823,15 +826,19 @@ 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));
IpResource ipResource = null; IpResource ipResource = null;
if (ipResourceRequestDto.getAddr() != null && ipResourceRequestDto.getAddr().size() > 0) if (ipResourceRequestDto.getAddr() != null && ipResourceRequestDto.getAddr().size() > 0)
ipResource = ipResourceRepository.findByAddrAndIsDeleted(ipResourceRequestDto.getAddr().get(0), false); ipResource = ipResourceRepository.findByAddrAndIsDeleted(ipResourceRequestDto.getAddr().get(0), false);
else if (ipResourceRequestDto.getIpId() != null && ipResourceRequestDto.getIpId().size() > 0) else if (ipResourceRequestDto.getIpId() != null && ipResourceRequestDto.getIpId().size() > 0) {
ipResource = ipResourceRepository.findByIdAndIsDeleted(ipResourceRequestDto.getIpId().get(0), false); String s = ipResourceRequestDto.getIpId().get(0);
else { ipResource = ipResourceRepository.findByIdAndIsDeleted(s, false);
} else {
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
...@@ -977,9 +984,9 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -977,9 +984,9 @@ public class IpResourceServiceImpl implements IpResourceService {
case 5: case 5:
// 已分配且未过期 // 已分配且未过期
ipResources = ipResourceRepository.findShopIdInList(shopIds, false) ipResources = ipResourceRepository.findShopIdInList(shopIds, false)
.stream() .stream()
.filter(x -> x.getValidTime() > Instant.now().toEpochMilli()) .filter(x -> x.getValidTime() > Instant.now().toEpochMilli())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!isParent) if (!isParent)
notUsed = ipResourceRepository.findByOwnerAndStatusInAndIsDeletedAndBind(username, Arrays.asList(0, 2, 4, 8), false, false); notUsed = ipResourceRepository.findByOwnerAndStatusInAndIsDeletedAndBind(username, Arrays.asList(0, 2, 4, 8), false, false);
else else
...@@ -1043,24 +1050,24 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -1043,24 +1050,24 @@ public class IpResourceServiceImpl implements IpResourceService {
private AtomicReference<Double> getDoubleAtomicReference(IpResourceRequestDto ipResourceRequestDto, Map<String, List<String>> ipPlatForm) { private AtomicReference<Double> getDoubleAtomicReference(IpResourceRequestDto ipResourceRequestDto, Map<String, List<String>> ipPlatForm) {
AtomicReference<Double> totalprice = new AtomicReference<>((double) 0); AtomicReference<Double> totalprice = new AtomicReference<>((double) 0);
ipResourceRequestDto.getAddr().stream() ipResourceRequestDto.getAddr().stream()
.map(x -> ipResourceRepository.findByAddrAndIsDeleted(x, false)) .map(x -> ipResourceRepository.findByAddrAndIsDeleted(x, false))
.forEach( .forEach(
ipResource -> { ipResource -> {
List<String> regionAndPriceInfos; List<String> regionAndPriceInfos;
if (!ipResourceRequestDto.getVendor().equals("own")) { if (!ipResourceRequestDto.getVendor().equals("own")) {
regionAndPriceInfos = ipPlatForm.get(ipResource.getRegionCn()); regionAndPriceInfos = ipPlatForm.get(ipResource.getRegionCn());
} else { } else {
regionAndPriceInfos = ipResource.isSpecialLine() ? ipPlatForm.get("自有专线") : ipPlatForm.get("自有"); regionAndPriceInfos = ipResource.isSpecialLine() ? ipPlatForm.get("自有专线") : ipPlatForm.get("自有");
} }
for (String vendorprice : regionAndPriceInfos) { for (String vendorprice : regionAndPriceInfos) {
if (ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-")))) if (ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-"))))
totalprice.updateAndGet( totalprice.updateAndGet(
v -> new Double(v + Double.valueOf(vendorprice.substring(vendorprice.lastIndexOf("-") + 1))) v -> new Double(v + Double.valueOf(vendorprice.substring(vendorprice.lastIndexOf("-") + 1)))
); );
} }
} }
); );
return totalprice; return totalprice;
} }
......
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