-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrderDao.java
32 lines (24 loc) · 866 Bytes
/
OrderDao.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.hudabanimustafa.pos.pos.dao;
import com.hudabanimustafa.pos.pos.dto.OrderDto;
import com.hudabanimustafa.pos.pos.entity.OrderEntity;
import com.hudabanimustafa.pos.pos.repository.OrderRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class OrderDao {
@Autowired
private OrderRepo orderRepo;
public OrderEntity saveOrder(List<OrderDto> order) {
Double total = 0.0;
for (OrderDto o : order) {
total += o.getProductPrice();
}
OrderEntity orderEntity = new OrderEntity();
orderEntity.setTotal(total);
return this.orderRepo.save(orderEntity);
}
public List<OrderEntity> getAllOrders() {
return this.orderRepo.findAll();
}
}