Commit 4e351823 authored by renjie's avatar renjie

白名单

本地ipbug
parent ef1b2105
...@@ -92,7 +92,7 @@ public class AccountController { ...@@ -92,7 +92,7 @@ public class AccountController {
// accountService.deleteByName(principal.getName()); // accountService.deleteByName(principal.getName());
// } // }
@RequestMapping(path = "/updatet", method = RequestMethod.POST) @RequestMapping(path = "/update", method = RequestMethod.POST)
public ResultDto saveCurrentAccount(Principal principal, @Valid @RequestBody Account account) { public ResultDto saveCurrentAccount(Principal principal, @Valid @RequestBody Account account) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
......
...@@ -41,67 +41,13 @@ public class Account { ...@@ -41,67 +41,13 @@ public class Account {
private boolean allowedToCreateSubUser = false; private boolean allowedToCreateSubUser = false;
private int permission = 00000000; private int permission = -1;
private Promotion promotion; private Promotion promotion;
private String comment; private String comment;
private List<String> whiteList = Arrays.asList( private List<String> whiteList = new ArrayList<>();
"amazon.cn",
"amazon.com",
"amazon.jp",
"amazon.co",
"amazon.ca",
"amazon.in",
"amazon.fr",
"amazon.it",
"amazon.de",
"amazon.es",
"amazon.sg",
"ebay.com",
"ebay.co",
"ebay.ca",
"ebay.de",
"ebay.es",
"ebay.fr",
"ebay.it",
"lazada.com",
"lazada.co",
"lazada.sg",
"lazada.vn",
"walmart.com",
"walmart.ca",
"shopee.cn",
"shopee.com",
"shopee.co",
"shopee.ph",
"shopee.sg",
"shopee.vn",
"paypal.com",
"wish.com",
"aliexpress.com",
"aliexpress.ru",
"pinduoduo.com",
"taobao.com",
"etsy.com",
"baidu.com",
"souq.com",
"joom.com",
"cdiscount.com",
"vova.com",
"eservicesgroup.com",
"factorymarket.com",
"factorymarket.de",
"yahoo.co.jp",
"yahoo.com",
"ezbuy.com",
"wayfair.com",
"yandex.com",
"rakuma.com",
"mymall.com",
"lilimall.com"
);
private int childCount = 0; private int childCount = 0;
......
package com.edgec.browserbackend.account.domain;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "whitelist")
public class WhiteSite {
@Id
private String id;
private String white;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getWhite() {
return white;
}
public void setWhite(String white) {
this.white = white;
}
}
...@@ -18,6 +18,7 @@ public class SubUsersRequestDto { ...@@ -18,6 +18,7 @@ public class SubUsersRequestDto {
private int permisson; private int permisson;
private String comment; private String comment;
private List<String> usernames; private List<String> usernames;
private List<String> whiteList;
public String getPassword() { public String getPassword() {
return password; return password;
...@@ -74,4 +75,12 @@ public class SubUsersRequestDto { ...@@ -74,4 +75,12 @@ public class SubUsersRequestDto {
public void setComment(String comment) { public void setComment(String comment) {
this.comment = comment; this.comment = comment;
} }
public List<String> getWhiteList() {
return whiteList;
}
public void setWhiteList(List<String> whiteList) {
this.whiteList = whiteList;
}
} }
package com.edgec.browserbackend.account.repository;
import com.edgec.browserbackend.account.domain.WhiteSite;
import org.springframework.data.mongodb.repository.MongoRepository;
public interface WhiteSiteRepository extends MongoRepository<WhiteSite, String> {
}
...@@ -71,9 +71,6 @@ public class AccountServiceImpl implements AccountService { ...@@ -71,9 +71,6 @@ public class AccountServiceImpl implements AccountService {
@Autowired @Autowired
private UserBillingRepository billingRepository; private UserBillingRepository billingRepository;
@Autowired
private UserRateRepository rateRepository;
@Autowired @Autowired
private UserPrePaidBillingRepository prePaidBillingRepository; private UserPrePaidBillingRepository prePaidBillingRepository;
...@@ -95,6 +92,9 @@ public class AccountServiceImpl implements AccountService { ...@@ -95,6 +92,9 @@ public class AccountServiceImpl implements AccountService {
@Autowired @Autowired
private IpResourceService ipResourceService; private IpResourceService ipResourceService;
@Autowired
private WhiteSiteRepository whiteSiteRepository;
@Override @Override
public List<UserBillList> getUserBills0(String name) { public List<UserBillList> getUserBills0(String name) {
...@@ -302,6 +302,11 @@ public class AccountServiceImpl implements AccountService { ...@@ -302,6 +302,11 @@ public class AccountServiceImpl implements AccountService {
if (ipSummary != null) if (ipSummary != null)
current.setIpSummary(ipSummary); current.setIpSummary(ipSummary);
List<String> whiteList = whiteSiteRepository.findAll().stream().map(x -> x.getWhite()).collect(Collectors.toList());
if (current.getWhiteList() != null && current.getWhiteList().size() > 0)
whiteList.addAll(current.getWhiteList());
current.setWhiteList(whiteList);
resultDto.setStatus(0); resultDto.setStatus(0);
resultDto.setData(current); resultDto.setData(current);
} catch (Exception e) { } catch (Exception e) {
...@@ -381,6 +386,11 @@ public class AccountServiceImpl implements AccountService { ...@@ -381,6 +386,11 @@ public class AccountServiceImpl implements AccountService {
account.setPromotion(new Promotion()); account.setPromotion(new Promotion());
account.setAllowedToCreateSubUser(true); account.setAllowedToCreateSubUser(true);
List<String> whiteList = new ArrayList<>();
if (user.getWhiteList() != null && user.getWhiteList().size() > 0)
whiteList.addAll(user.getWhiteList());
account.setWhiteList(whiteList);
user.setEnabled(true); user.setEnabled(true);
userAuthService.create(new com.edgec.browserbackend.auth.domain.User(user)); userAuthService.create(new com.edgec.browserbackend.auth.domain.User(user));
...@@ -555,6 +565,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -555,6 +565,10 @@ public class AccountServiceImpl implements AccountService {
userAuthService.create(new com.edgec.browserbackend.auth.domain.User(authUser)); userAuthService.create(new com.edgec.browserbackend.auth.domain.User(authUser));
Account account = new Account(user); Account account = new Account(user);
List<String> whiteList = new ArrayList<>();
if (user.getWhiteList() != null && user.getWhiteList().size() > 0)
whiteList.addAll(user.getWhiteList());
account.setWhiteList(whiteList);
account.setPhoneNumber(user.getPhoneNumber()); account.setPhoneNumber(user.getPhoneNumber());
account.setEmail(user.getEmail()); account.setEmail(user.getEmail());
account.setParent(name); account.setParent(name);
...@@ -623,6 +637,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -623,6 +637,10 @@ public class AccountServiceImpl implements AccountService {
account.setPhoneNumber(existing.getPhoneNumber()); account.setPhoneNumber(existing.getPhoneNumber());
account.setParent(name); account.setParent(name);
account.setPermission(subUsersRequestDto.getPermission()); account.setPermission(subUsersRequestDto.getPermission());
List<String> whiteList = new ArrayList<>();
if (user.getWhiteList() != null && user.getWhiteList().size() > 0)
whiteList.addAll(user.getWhiteList());
account.setWhiteList(whiteList);
repository.save(account); repository.save(account);
// emailService.sendEmailVerification(user.getUsername(), user.getEmail(), user.getVerificationCode()); // emailService.sendEmailVerification(user.getUsername(), user.getEmail(), user.getVerificationCode());
...@@ -644,6 +662,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -644,6 +662,10 @@ public class AccountServiceImpl implements AccountService {
childAccount.setJobTitle(user.getJobTitle()); childAccount.setJobTitle(user.getJobTitle());
childAccount.setCompanyName(user.getCompanyName()); childAccount.setCompanyName(user.getCompanyName());
childAccount.setPermission(user.getPermission()); childAccount.setPermission(user.getPermission());
List<String> whiteList = childAccount.getWhiteList();
if (user.getWhiteList() != null && user.getWhiteList().size() > 0)
whiteList.addAll(user.getWhiteList());
childAccount.setWhiteList(whiteList);
repository.save(childAccount); repository.save(childAccount);
return childAccount; return childAccount;
} }
...@@ -668,6 +690,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -668,6 +690,10 @@ public class AccountServiceImpl implements AccountService {
childAccount.setPermission(subUsersRequestDto.getPermission()); childAccount.setPermission(subUsersRequestDto.getPermission());
if (subUsersRequestDto.getComment() != null) if (subUsersRequestDto.getComment() != null)
childAccount.setComment(subUsersRequestDto.getComment()); childAccount.setComment(subUsersRequestDto.getComment());
List<String> whiteList = new ArrayList<>();
if (subUsersRequestDto.getWhiteList() != null && subUsersRequestDto.getWhiteList().size() > 0)
whiteList.addAll(subUsersRequestDto.getWhiteList());
childAccount.setWhiteList(whiteList);
repository.save(childAccount); repository.save(childAccount);
} }
...@@ -683,14 +709,24 @@ public class AccountServiceImpl implements AccountService { ...@@ -683,14 +709,24 @@ public class AccountServiceImpl implements AccountService {
if (account == null) if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "can't find account with name " + name); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "can't find account with name " + name);
String preEmail = account.getEmail(); String preEmail = account.getEmail();
account.setNote(update.getNote()); if (update.getNote() != null)
account.setNote(update.getNote());
account.setLastSeen(new Date()); account.setLastSeen(new Date());
account.setCompanyName(update.getCompanyName()); if (update.getCompanyName() != null)
account.setJobTitle(update.getJobTitle()); account.setCompanyName(update.getCompanyName());
if (update.getJobTitle() != null)
account.setJobTitle(update.getJobTitle());
// account.setPhoneNumber(update.getPhoneNumber()); // account.setPhoneNumber(update.getPhoneNumber());
account.setEmail(update.getEmail()); if (update.getEmail() != null)
account.setPermission(update.getPermission()); account.setEmail(update.getEmail());
account.setWhiteList(update.getWhiteList()); if (update.getPermission() != -1)
account.setPermission(update.getPermission());
List<String> whiteList = account.getWhiteList();
if (update.getWhiteList() != null && update.getWhiteList().size() > 0)
whiteList.addAll(update.getWhiteList());
account.setWhiteList(whiteList);
log.debug("account {} changes has been saved", name); log.debug("account {} changes has been saved", name);
if (!org.apache.commons.lang3.StringUtils.equalsIgnoreCase(preEmail, update.getEmail())) { if (!org.apache.commons.lang3.StringUtils.equalsIgnoreCase(preEmail, update.getEmail())) {
Account account1 = repository.findByEmail(update.getEmail()); Account account1 = repository.findByEmail(update.getEmail());
......
...@@ -423,7 +423,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -423,7 +423,7 @@ public class ShopServiceImpl implements ShopService {
return new ShopPageResultDto(); return new ShopPageResultDto();
List<ShopResultDto> shopResultDtos = new ArrayList<>(); List<ShopResultDto> shopResultDtos = new ArrayList<>();
shops.getContent().stream().forEach(x -> { shops.getContent().stream().forEach(x -> {
IpResource ipResource = ipResourceRepository.findByAddrAndIsDeleted(x.getIp(), false); IpResource ipResource = ipResourceRepository.findByIdAndIsDeleted(x.getIpId(), false);
if (ipResource == null) if (ipResource == null)
ipResource = new IpResource(); ipResource = new IpResource();
String group1 = userShopRepository.findByUsernameAndShopId(username, x.getShopId()).getGroupId(); String group1 = userShopRepository.findByUsernameAndShopId(username, x.getShopId()).getGroupId();
......
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