This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "brandName": "Kook N Keech", | |
| "productName": "Striped Pure Cotton Relaxed T-shirt", | |
| "price": { | |
| "mrp": 1099, | |
| "fsp": 494, | |
| "discount": "55" | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Myntra Page : https://www.myntra.com/men-tshirts | |
| const productResultsContainer = document.querySelector('#desktopSearchResults > div.search-searchProductsContainer.row-base > section > ul') | |
| const productResultNodes = productResultsContainer ? Array.from(productResultsContainer.querySelectorAll('li')) : [] | |
| const final = [] | |
| productResultNodes.forEach((productNode)=>{ | |
| const productDataNode = productNode.querySelector('a > div.product-productMetaInfo'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Run the following script on any page following this url pattern : https://grofers.com/cn/<some-category>/cid/1487 | |
| * Variable result at the end of execution will have the list of all products in the particular category | |
| **/ | |
| const products=document.querySelectorAll('.plp-product'); | |
| const category=location.pathname.split('/')[2].split('-').join('_') | |
| const result=[]; | |
| products.forEach(p=>{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.demo.SpringMongoCRUD.controller; | |
| import com.demo.SpringMongoCRUD.exception.MovieCollectionException; | |
| import com.demo.SpringMongoCRUD.model.Movie; | |
| import com.demo.SpringMongoCRUD.service.MovieService; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.web.bind.annotation.*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void updateMovie(String id,Movie newMovie) throws ConstraintViolationException,MovieCollectionException | |
| { | |
| Optional<Movie> movieWithId=movieRepo.findById(id); | |
| Optional<Movie> movieWithSameTitle=movieRepo.findByTitle(newMovie.getTitle()); | |
| if(movieWithId.isPresent()) | |
| { | |
| if(movieWithSameTitle.isPresent() && !movieWithSameTitle.get().getId().equals(id)) | |
| { | |
| throw new MovieCollectionException(MovieCollectionException.TitleAlreadyExists()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.demo.SpringMongoCRUD.repository; | |
| import com.demo.SpringMongoCRUD.model.Movie; | |
| import org.springframework.data.mongodb.repository.MongoRepository; | |
| import org.springframework.data.mongodb.repository.Query; | |
| import java.util.Optional; | |
| public interface MovieRepository extends MongoRepository<Movie,String> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void createMovie(Movie movie) throws ConstraintViolationException,MovieCollectionException | |
| { | |
| Optional<Movie> movieNameOptional=movieRepo.findByTitle(movie.getTitle()); | |
| if(movieNameOptional.isPresent()) | |
| { | |
| throw new MovieCollectionException(MovieCollectionException.TitleAlreadyExists()); | |
| } | |
| else | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void deleteMovieById(String id) throws MovieCollectionException | |
| { | |
| Optional<Movie> movieOptional=movieRepo.findById(id); | |
| if(!movieOptional.isPresent()) | |
| { | |
| throw new MovieCollectionException(MovieCollectionException.NotFoundException(id)); | |
| } | |
| else | |
| { | |
| movieRepo.deleteById(id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public List<Movie> getAllMovies() | |
| { | |
| List<Movie> movies=movieRepo.findAll(); | |
| if(movies.size()>0) | |
| { | |
| return movies; | |
| } | |
| else | |
| { | |
| return new ArrayList<Movie>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.demo.SpringMongoCRUD.exception; | |
| public class MovieCollectionException extends Exception { | |
| public MovieCollectionException(String message) | |
| { | |
| super(message); | |
| } | |
| public static String NotFoundException(String id) |
NewerOlder