Advertisement
nikeza

Untitled

Mar 22nd, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1.  
  2.         products.forEach(productSeedDto -> {
  3.             if (this.validationUtil.isValid(productSeedDto)) {
  4.                 if (this.productRepository.findByName(productSeedDto.getName()) == null) {
  5.  
  6.                     Product product = this.modelMapper
  7.                             .map(productSeedDto, Product.class);
  8.  
  9.                     User userB = this.userService.getRandomUser();
  10.  
  11.                     int num = this.random.nextInt(5) + 1;
  12.                     if (num <3) {
  13.                         product.setBuyerId(userB);
  14.                     }
  15.  
  16.                     User userS = this.userService.getRandomUser();
  17.                     if (product.getBuyerId() != null && userS.getLastName().equals(product.getBuyerId().getLastName())) {
  18.                         userS = this.userService.getRandomUser();
  19.                     }
  20.                     product.setSellerId(userS);
  21.  
  22.                     this.productRepository.saveAndFlush(product);
  23.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement