Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- products.forEach(productSeedDto -> {
- if (this.validationUtil.isValid(productSeedDto)) {
- if (this.productRepository.findByName(productSeedDto.getName()) == null) {
- Product product = this.modelMapper
- .map(productSeedDto, Product.class);
- User userB = this.userService.getRandomUser();
- int num = this.random.nextInt(5) + 1;
- if (num <3) {
- product.setBuyerId(userB);
- }
- User userS = this.userService.getRandomUser();
- if (product.getBuyerId() != null && userS.getLastName().equals(product.getBuyerId().getLastName())) {
- userS = this.userService.getRandomUser();
- }
- product.setSellerId(userS);
- this.productRepository.saveAndFlush(product);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement