-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderRepositoryImpl.java
More file actions
38 lines (27 loc) · 944 Bytes
/
OrderRepositoryImpl.java
File metadata and controls
38 lines (27 loc) · 944 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
35
36
37
38
package com.welflex.aws.dynamodb.repository;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
import com.welflex.aws.dynamodb.model.Order;
import java.util.List;
public class OrderRepositoryImpl {
private final DynamoDBMapper mapper;
public OrderRepositoryImpl(AmazonDynamoDB dynamoDB) {
this.mapper = new DynamoDBMapper(dynamoDB);
}
public Order save(Order order) {
mapper.save(order);
return order;
}
public Order get(String id) {
return mapper.load(Order.class, id);
}
public void delete(String id) {
Order order = new Order();
order.setId(id);
mapper.delete(order);
}
public List<Order> getAll() {
return mapper.scan(Order.class, new DynamoDBScanExpression());
}
}