Commit 4e351823 authored by renjie's avatar renjie

白名单

本地ipbug
parent ef1b2105
......@@ -92,7 +92,7 @@ public class AccountController {
// 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) {
ResultDto resultDto = new ResultDto();
try {
......
......@@ -41,67 +41,13 @@ public class Account {
private boolean allowedToCreateSubUser = false;
private int permission = 00000000;
private int permission = -1;
private Promotion promotion;
private String comment;
private List<String> whiteList = Arrays.asList(
"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 List<String> whiteList = new ArrayList<>();
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 {
private int permisson;
private String comment;
private List<String> usernames;
private List<String> whiteList;
public String getPassword() {
return password;
......@@ -74,4 +75,12 @@ public class SubUsersRequestDto {
public void setComment(String 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 {
@Autowired
private UserBillingRepository billingRepository;
@Autowired
private UserRateRepository rateRepository;
@Autowired
private UserPrePaidBillingRepository prePaidBillingRepository;
......@@ -95,6 +92,9 @@ public class AccountServiceImpl implements AccountService {
@Autowired
private IpResourceService ipResourceService;
@Autowired
private WhiteSiteRepository whiteSiteRepository;
@Override
public List<UserBillList> getUserBills0(String name) {
......@@ -302,6 +302,11 @@ public class AccountServiceImpl implements AccountService {
if (ipSummary != null)
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.setData(current);
} catch (Exception e) {
......@@ -381,6 +386,11 @@ public class AccountServiceImpl implements AccountService {
account.setPromotion(new Promotion());
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);
userAuthService.create(new com.edgec.browserbackend.auth.domain.User(user));
......@@ -555,6 +565,10 @@ public class AccountServiceImpl implements AccountService {
userAuthService.create(new com.edgec.browserbackend.auth.domain.User(authUser));
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.setEmail(user.getEmail());
account.setParent(name);
......@@ -623,6 +637,10 @@ public class AccountServiceImpl implements AccountService {
account.setPhoneNumber(existing.getPhoneNumber());
account.setParent(name);
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);
// emailService.sendEmailVerification(user.getUsername(), user.getEmail(), user.getVerificationCode());
......@@ -644,6 +662,10 @@ public class AccountServiceImpl implements AccountService {
childAccount.setJobTitle(user.getJobTitle());
childAccount.setCompanyName(user.getCompanyName());
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);
return childAccount;
}
......@@ -668,6 +690,10 @@ public class AccountServiceImpl implements AccountService {
childAccount.setPermission(subUsersRequestDto.getPermission());
if (subUsersRequestDto.getComment() != null)
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);
}
......@@ -683,14 +709,24 @@ public class AccountServiceImpl implements AccountService {
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "can't find account with name " + name);
String preEmail = account.getEmail();
account.setNote(update.getNote());
if (update.getNote() != null)
account.setNote(update.getNote());
account.setLastSeen(new Date());
account.setCompanyName(update.getCompanyName());
account.setJobTitle(update.getJobTitle());
if (update.getCompanyName() != null)
account.setCompanyName(update.getCompanyName());
if (update.getJobTitle() != null)
account.setJobTitle(update.getJobTitle());
// account.setPhoneNumber(update.getPhoneNumber());
account.setEmail(update.getEmail());
account.setPermission(update.getPermission());
account.setWhiteList(update.getWhiteList());
if (update.getEmail() != null)
account.setEmail(update.getEmail());
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);
if (!org.apache.commons.lang3.StringUtils.equalsIgnoreCase(preEmail, update.getEmail())) {
Account account1 = repository.findByEmail(update.getEmail());
......
......@@ -423,7 +423,7 @@ public class ShopServiceImpl implements ShopService {
return new ShopPageResultDto();
List<ShopResultDto> shopResultDtos = new ArrayList<>();
shops.getContent().stream().forEach(x -> {
IpResource ipResource = ipResourceRepository.findByAddrAndIsDeleted(x.getIp(), false);
IpResource ipResource = ipResourceRepository.findByIdAndIsDeleted(x.getIpId(), false);
if (ipResource == null)
ipResource = new IpResource();
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