Compare commits
2 Commits
0174224089
...
728cb4f84f
| Author | SHA1 | Date | |
|---|---|---|---|
| 728cb4f84f | |||
| 5140228f3e |
@ -0,0 +1,35 @@
|
||||
package ru.kamask.pet.todo.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import ru.kamask.pet.todo.model.Identifiable;
|
||||
import ru.kamask.pet.todo.repo.Repository;
|
||||
|
||||
public class EntityService<T extends Identifiable> {
|
||||
private final Repository<T> repo;
|
||||
|
||||
protected EntityService(Repository<T> repo) {
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
protected void save(T obj) {
|
||||
repo.save(obj);
|
||||
}
|
||||
|
||||
protected Optional<T> getById(int id) {
|
||||
return repo.findById(id);
|
||||
}
|
||||
|
||||
protected List<T> getAll() {
|
||||
return repo.findAll();
|
||||
}
|
||||
|
||||
protected void remove(int id) {
|
||||
repo.delete(id);
|
||||
}
|
||||
|
||||
protected boolean has(int id) {
|
||||
return repo.has(id);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user