use of com.zavada.entity.ProductEntity in project Logos_Materials_October_2017 by VolodymyrZavada.
the class SpringBootConsultationProjectApplication method addProducts.
static void addProducts(ConfigurableApplicationContext context) {
ProductRepository productRepository = context.getBean(ProductRepository.class);
ProductEntity product = productRepository.findOne(1);
if (product == null) {
productRepository.save(getProducts());
}
}
use of com.zavada.entity.ProductEntity in project Logos_Materials_October_2017 by VolodymyrZavada.
the class RestController method buy.
@GetMapping("/buy")
public ResponseEntity<?> buy(@RequestParam("productid") String prodIdStr) {
int productId = Integer.valueOf(prodIdStr);
ProductEntity entity = productService.findProductById(productId);
entity.setInStock(entity.getInStock() - 1);
productService.saveOrUpdate(entity);
return new ResponseEntity<>(HttpStatus.OK);
}
use of com.zavada.entity.ProductEntity in project Logos_Materials_October_2017 by VolodymyrZavada.
the class SpringBootConsultationProjectApplication method getProducts.
private static List<ProductEntity> getProducts() {
List<ProductEntity> productEntities = new ArrayList<>();
productEntities.add(new ProductEntity("MacBook Pro (15 inch)", 2999, 50, "Apple"));
productEntities.add(new ProductEntity("Samsung Galaxy Note 7", 899, 199, "Samsung"));
productEntities.add(new ProductEntity("HP Officejet 5740", 899, 12, "HP"));
productEntities.add(new ProductEntity("iPhone X", 999, 3, "Apple"));
productEntities.add(new ProductEntity("iPad Pro (9.7 inch)", 699, 30, "Apple"));
productEntities.add(new ProductEntity("OnePlus 3 cover", 449, 0, "OnePlus"));
return productEntities;
}
Aggregations