use of com.ncedu.fooddelivery.api.v1.entities.Product in project 2021-msk-food-delivery by netcracker-edu.
the class ProductUtils method createProductUpdateDTO.
public static ProductUpdateDTO createProductUpdateDTO(Product p) {
ProductUpdateDTO productDTO = new ProductUpdateDTO();
productDTO.setDescription(p.getDescription());
productDTO.setPrice(p.getPrice());
productDTO.setName(p.getName());
productDTO.setWeight(p.getWeight());
productDTO.setExpirationDays(p.getExpirationDays());
return productDTO;
}
use of com.ncedu.fooddelivery.api.v1.entities.Product 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;
}
use of com.ncedu.fooddelivery.api.v1.entities.Product in project C-DAC-Notes by shreeshailaya.
the class CategoryCriteria method main.
public static void main(String[] args) {
StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build();
Metadata metadata = new MetadataSources(registry).getMetadataBuilder().build();
SessionFactory sf = metadata.getSessionFactoryBuilder().build();
System.out.println("session factory created");
Session session = sf.openSession();
// create criteria builder
CriteriaBuilder builder = session.getCriteriaBuilder();
// create criteria query
CriteriaQuery<Object[]> query = builder.createQuery(Object[].class);
// specify root ie from clause
Root<Product> from = query.from(Product.class);
// specify select clause, where clause
query.multiselect(from.get("description"), from.get("name")).where(builder.equal(from.get("id"), 1));
// create query from criteria provided
Query q = session.createQuery(query);
List<Object[]> ques = q.getResultList();
for (Object[] qu : ques) System.out.println(qu[0] + " : ");
}
use of com.ncedu.fooddelivery.api.v1.entities.Product in project ADS_Senac by Renan-Paiva93.
the class mediaProduto method main.
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
// indicar vetor tipo do vetor com N Elementos
Product[] vect = new Product[n];
// for (int i = 0; i < n; i++)
for (int i = 0; i < vect.length; i++) {
sc.nextLine();
String name = sc.nextLine();
double price = sc.nextDouble();
// estanciar para novo produto e apontar para os objetos
vect[i] = new Product(name, price);
}
// média dos preços
double soma = 0;
for (int i = 0; i < vect.length; i++) {
soma += vect[i].getPrice();
}
// média
double avg = soma / vect.length;
System.out.printf("average price = %.2f%n", avg);
}
Aggregations