-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTotalOrderService.java
More file actions
34 lines (29 loc) · 1.02 KB
/
TotalOrderService.java
File metadata and controls
34 lines (29 loc) · 1.02 KB
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
33
34
package com.example.order.service;
import com.example.order.dao.TotalOrderDao;
import com.example.order.dto.ParamsDto;
import com.example.order.util.Database;
import java.io.IOException;
import java.math.BigDecimal;
import java.sql.SQLException;
/**
* Service class to get the total of the orders of a customer
*/
public class TotalOrderService implements OrderService {
private final TotalOrderDao totalOrderDao = new TotalOrderDao(Database.getInstance());
/**
* Method to execute the service operation
*
* @param paramsDTO Object with the parameters to execute the service
*/
@Override
public String execute(ParamsDto paramsDTO) throws IOException, SQLException {
String result;
BigDecimal total = totalOrderDao.getTotalAllPaidOrders(paramsDTO);
if (total != null) {
result = "Total: " + total.toString();
} else {
result = "No paid orders for the customer with ID " + paramsDTO.getCustomerId() + " found";
}
return result;
}
}