forked from VolodymyrPortianko/topjava03
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserMealServiceImpl.java
More file actions
56 lines (45 loc) · 1.45 KB
/
UserMealServiceImpl.java
File metadata and controls
56 lines (45 loc) · 1.45 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ru.javawebinar.topjava.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ru.javawebinar.topjava.model.UserMeal;
import ru.javawebinar.topjava.repository.UserMealRepository;
import ru.javawebinar.topjava.util.exception.ExceptionUtil;
import java.time.LocalDateTime;
import java.util.List;
/**
* GKislin
* 06.03.2015.
*/
@Service
public class UserMealServiceImpl implements UserMealService {
@Autowired
private UserMealRepository repository;
@Override
public UserMeal get(int id, int userId) {
return ExceptionUtil.check(repository.get(id, userId), id);
}
@Override
public void delete(int id, int userId) {
ExceptionUtil.check(repository.delete(id, userId), id);
}
@Override
public List<UserMeal> getBetweenDateTimes(LocalDateTime startDate, LocalDateTime endDate, int userId) {
return repository.getBetween(startDate, endDate, userId);
}
@Override
public List<UserMeal> getAll(int userId) {
return repository.getAll(userId);
}
@Override
public void deleteAll(int userId) {
repository.deleteAll(userId);
}
@Override
public UserMeal update(UserMeal meal, int userId) {
return ExceptionUtil.check(repository.save(meal, userId), meal.getId());
}
@Override
public UserMeal save(UserMeal meal, int userId) {
return repository.save(meal, userId);
}
}