-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertOrderService.java
More file actions
34 lines (28 loc) · 957 Bytes
/
InsertOrderService.java
File metadata and controls
34 lines (28 loc) · 957 Bytes
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.InsertOrderDao;
import com.example.order.dto.ParamsDto;
import com.example.order.util.Database;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
/**
* Service class to insert an order
*/
public class InsertOrderService implements OrderService {
InsertOrderDao insertOrderDao = new InsertOrderDao(Database.getInstance());
/**
* Method to execute the service operation
*
* @param paramsDTO Object with the parameters to execute the service
*/
@Override
public String execute(@NotNull ParamsDto paramsDTO) throws IOException {
String result;
long orderId = insertOrderDao.insertOrder(paramsDTO.getOrder());
if (orderId > 0) {
result = "A new order with the ID " + orderId + " was inserted";
} else {
result = "No order was inserted";
}
return result;
}
}