use of com.ncedu.fooddelivery.api.v1.dto.product.ProductCreateDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductUtils method createProductCreateDTO.
public static ProductCreateDTO createProductCreateDTO(Product p) {
ProductCreateDTO productDTO = new ProductCreateDTO();
productDTO.setDescription(p.getDescription());
productDTO.setPrice(p.getPrice());
productDTO.setName(p.getName());
productDTO.setInShowcase(p.getInShowcase());
productDTO.setWeight(p.getWeight());
productDTO.setExpirationDays(p.getExpirationDays());
return productDTO;
}
use of com.ncedu.fooddelivery.api.v1.dto.product.ProductCreateDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceImpl method createProduct.
@Override
public isCreatedDTO createProduct(ProductCreateDTO newProduct) {
Product product = productMapper.mapToEntity(newProduct);
product = productRepo.save(product);
isCreatedDTO createdDTO = new isCreatedDTO();
createdDTO.setId(product.getId());
return createdDTO;
}
use of com.ncedu.fooddelivery.api.v1.dto.product.ProductCreateDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductController method createProduct.
@PostMapping("/api/v1/product")
@PreAuthorize("hasAuthority('ADMIN')")
public isCreatedDTO createProduct(@Valid @RequestBody ProductCreateDTO newProduct) {
isCreatedDTO createdDTO = productService.createProduct(newProduct);
log.debug("Created product with id: " + createdDTO.getId());
return createdDTO;
}
Aggregations