Commit 826c0694 authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

Staging

See merge request !66
parents d8b94347 5845cc6a
...@@ -396,6 +396,24 @@ public class AdministratorController { ...@@ -396,6 +396,24 @@ public class AdministratorController {
return resultDto; return resultDto;
} }
//添加白名单
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/userwhitelist/add", method = RequestMethod.PUT)
public ResultDto addWhiteList(Principal principal, @RequestParam("username") String username, @RequestParam("website") String website) {
ResultDto resultDto = new ResultDto();
try {
administratorService.addUserWhiteList(username, website);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
}
//统计ip数量 //统计ip数量
@PreAuthorize(Securitys.ADMIN_EL) @PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/ip/count", method = RequestMethod.GET) @RequestMapping(path = "/0xadministrator/ip/count", method = RequestMethod.GET)
...@@ -448,7 +466,7 @@ public class AdministratorController { ...@@ -448,7 +466,7 @@ public class AdministratorController {
response.setHeader("content-type", "application/octet-stream"); response.setHeader("content-type", "application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("3proxy.cfg", "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("3proxy.cfg", "UTF-8"));
int len =0; int len =0;
byte[] bt = new byte[5*1024]; byte[] bt = new byte[50*1024];
while((len = fis.read(bt)) != -1) { while((len = fis.read(bt)) != -1) {
os.write(bt,0,len); os.write(bt,0,len);
} }
......
...@@ -62,5 +62,7 @@ public interface AdministratorService { ...@@ -62,5 +62,7 @@ public interface AdministratorService {
void addWhiteList(String website); void addWhiteList(String website);
void addUserWhiteList(String username, String website);
File getProxyConfig(); File getProxyConfig();
} }
...@@ -465,6 +465,15 @@ public class AdministratorServiceImpl implements AdministratorService { ...@@ -465,6 +465,15 @@ public class AdministratorServiceImpl implements AdministratorService {
whiteSiteRepository.save(whiteSite); whiteSiteRepository.save(whiteSite);
} }
@Override
public void addUserWhiteList(String username, String website) {
Account account = accountRepository.findByName(username);
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
account.getWhiteList().add(website);
accountRepository.save(account);
}
@Override @Override
public File getProxyConfig() { public File getProxyConfig() {
ProxyConfig proxyConfig = null; ProxyConfig proxyConfig = null;
......
...@@ -29,6 +29,7 @@ public class IpResourceRequestDto { ...@@ -29,6 +29,7 @@ public class IpResourceRequestDto {
private int ipkeptperiod = 7; private int ipkeptperiod = 7;
private String startscript = ""; private String startscript = "";
private boolean specialLine;
//自有IP需要传proxy的账号 //自有IP需要传proxy的账号
private String username; private String username;
private String password; private String password;
...@@ -206,4 +207,12 @@ public class IpResourceRequestDto { ...@@ -206,4 +207,12 @@ public class IpResourceRequestDto {
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
public boolean isSpecialLine() {
return specialLine;
}
public void setSpecialLine(boolean specialLine) {
this.specialLine = specialLine;
}
} }
...@@ -251,9 +251,10 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -251,9 +251,10 @@ public class IpResourceServiceImpl implements IpResourceService {
} else if (ipResourceRequestDto.getVendor().equals("own")) { } else if (ipResourceRequestDto.getVendor().equals("own")) {
if (ipResourceRequestDto.getAddr() == null || ipResourceRequestDto.getAddr().size() == 0) if (ipResourceRequestDto.getAddr() == null || ipResourceRequestDto.getAddr().size() == 0)
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
if (StringUtils.isBlank(ipResourceRequestDto.getAddr().get(0))) if (StringUtils.isBlank(ipResourceRequestDto.getAddr().get(i)))
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
ipResource.setAddr(ipResourceRequestDto.getAddr().get(0)); ipResource.setSpecialLine(ipResourceRequestDto.isSpecialLine());
ipResource.setAddr(ipResourceRequestDto.getAddr().get(i));
ipResource.setIpType(IpType.OWN); ipResource.setIpType(IpType.OWN);
ipResource.setVendor(Vendor.valueOf(ipResourceRequestDto.getVendor())); ipResource.setVendor(Vendor.valueOf(ipResourceRequestDto.getVendor()));
ipResource.setVendorCn("自有"); ipResource.setVendorCn("自有");
...@@ -337,8 +338,12 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -337,8 +338,12 @@ public class IpResourceServiceImpl implements IpResourceService {
List<String> prices; List<String> prices;
if (!ipResourceRequestDto.getVendor().equals("own")) if (!ipResourceRequestDto.getVendor().equals("own"))
prices = priceList.get(ipResource.getRegionCn()); prices = priceList.get(ipResource.getRegionCn());
else else {
prices = priceList.get("自有"); if (ipResource.isSpecialLine())
prices = priceList.get("自有专线");
else
prices = priceList.get("自有");
}
for(String vendorprice:prices) { for(String vendorprice:prices) {
if (ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-")))) if (ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-"))))
totalprice.updateAndGet(v -> new Double( v + Double.valueOf(vendorprice.substring(vendorprice.lastIndexOf("-") + 1)))); totalprice.updateAndGet(v -> new Double( v + Double.valueOf(vendorprice.substring(vendorprice.lastIndexOf("-") + 1))));
...@@ -399,8 +404,13 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -399,8 +404,13 @@ public class IpResourceServiceImpl implements IpResourceService {
List<String> vendorPrices; List<String> vendorPrices;
if (!ipResourceRequestDto.getVendor().equals("own")) if (!ipResourceRequestDto.getVendor().equals("own"))
vendorPrices = priceList.get(ipResource.getRegionCn()); vendorPrices = priceList.get(ipResource.getRegionCn());
else else {
vendorPrices = priceList.get("自有"); if (ipResource.isSpecialLine())
vendorPrices = priceList.get("自有专线");
else
vendorPrices = priceList.get("自有");
}
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)).collect(Collectors.joining()); .map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1)).collect(Collectors.joining());
......
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