Commit 1ee52a4d authored by jim's avatar jim

log

parent b89daafd
......@@ -69,12 +69,12 @@ public class ShopServiceImpl implements ShopService {
}
if (shopResultDto.getGroup() != null) {
Group group = groupRepository.findById(shopResultDto.getGroup())
.orElseThrow(() -> new ClientRequestException(BrowserErrorCode.GROUPNOTEXIST));
.orElseThrow(() -> new ClientRequestException(BrowserErrorCode.GROUPNOTEXIST));
}
// 2. 对当前用户的 account 信息进行校验
Account account = accountRepository.findByName(username)
.orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
.orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
if (account.getPermission() < 4) {
throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
}
......@@ -102,7 +102,7 @@ public class ShopServiceImpl implements ShopService {
userShopRepository.save(userShop1);
Account parentAccount = accountRepository.findByName(account.getParent())
.orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
.orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
account.setShopCount(parentAccount.getShopCount() + 1);
accountRepository.save(parentAccount);
}
......@@ -161,7 +161,7 @@ public class ShopServiceImpl implements ShopService {
userShopRepository.save(userShop1);
Account parentAccount = accountRepository.findByName(account.getParent())
.orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
.orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
account.setShopCount(parentAccount.getShopCount() + 1);
accountRepository.save(parentAccount);
}
......@@ -372,14 +372,14 @@ public class ShopServiceImpl implements ShopService {
List<String> allIds = null;
if ("-1".equals(groupId)) {
allIds = userShopRepository.findByUsername(username).stream()
.map(UserShop::getShopId).collect(Collectors.toList());
.map(UserShop::getShopId).collect(Collectors.toList());
// 如果分组
} else {
allIds = userShopRepository.findByUsernameAndGroupId(username, groupId).stream()
.map(UserShop::getShopId).collect(Collectors.toList());
.map(UserShop::getShopId).collect(Collectors.toList());
}
List<String> shopIds = null;
List<String> shopIds = new ArrayList<>();
if (shopFilterDto.getBindIp() == 0) {
shopIds = allIds;
......@@ -387,7 +387,7 @@ public class ShopServiceImpl implements ShopService {
} else if (shopFilterDto.getBindIp() == 1) {
// ip资源已经分配了 的店铺
shopIds = ipResourceRepository.findShopIdInList(allIds, false).stream()
.flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
.flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
// 这个地方的其他情况是指什么情况
} else {
......@@ -400,7 +400,7 @@ public class ShopServiceImpl implements ShopService {
}
}
amount = amount > 100 ? 100 : amount;
amount = Math.min(amount, 100);
Pageable pageable = PageRequest.of(pageNum, amount);
// 根据商铺ids 与 过滤条件 得到商铺
Page<Shop> shops = getShopsByFilter(shopFilterDto, shopIds, pageable);
......@@ -408,7 +408,7 @@ public class ShopServiceImpl implements ShopService {
ShopPageResultDto<ShopResultDto> shopPageResultDto = new ShopPageResultDto<>();
if (shops != null && shops.getNumberOfElements() >= 1) {
List<ShopResultDto> shopResultDtos = new ArrayList<>();
shops.getContent().stream().forEach(
shops.getContent().forEach(
x -> {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(x.getShopId(), false);
// 如果 ip资源非空 且 addr 也非空
......@@ -476,10 +476,9 @@ public class ShopServiceImpl implements ShopService {
public ShopSummary getShopSummary(String username) {
Account account = accountRepository.findByName(username).orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
ShopSummary shopSummary = new ShopSummary();
List<String> allShopIds = userShopRepository.findByUsername(username).stream()
.map(UserShop::getShopId).collect(Collectors.toList());
.map(UserShop::getShopId).collect(Collectors.toList());
List<String> unbind = new ArrayList<>();
if (!allShopIds.isEmpty()) {
for (String id : allShopIds) {
......@@ -492,9 +491,9 @@ public class ShopServiceImpl implements ShopService {
shopSummary.setUnbind(unbind.size());
List<String> shopIds = userShopRepository.findByUsername(username).stream()
.map(UserShop::getShopId).collect(Collectors.toList());
.map(UserShop::getShopId).collect(Collectors.toList());
List<String> bind = ipResourceRepository.findShopIdInList(shopIds, false).stream()
.map(IpResource::getId).collect(Collectors.toList());
.map(IpResource::getId).collect(Collectors.toList());
int expired = ipResourceRepository.countByStatusAndIdInAndIsDeleted(1, bind, false);
int willexpired = ipResourceRepository.countByStatusAndIdInAndIsDeleted(2, bind, false);
shopSummary.setExpired(expired);
......@@ -560,7 +559,7 @@ public class ShopServiceImpl implements ShopService {
Page<Shop> shops = null;
if (!StringUtils.isEmpty(shopFilterDto.getIpRegion())) {
List<String> filter = ipResourceRepository.findShopIdInListAndRegionLike(shopIds, false, shopFilterDto.getIpRegion())
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
shops = shopRepository.findByShopIdInOrderByCreateTimeDesc(filter, pageable);
}
if (!StringUtils.isEmpty(shopFilterDto.getShopAccount())) {
......
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