-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathPersonService.java
More file actions
43 lines (31 loc) · 1.04 KB
/
PersonService.java
File metadata and controls
43 lines (31 loc) · 1.04 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
package io.zipcoder.crudapp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class PersonService {
private PersonRepository repository;
@Autowired
public PersonService(PersonRepository repository){
this.repository = repository;
}
public Iterable<Person> findAllPeople () {
return repository.findAll();
}
public Person findOnePerson (Integer id){
return repository.findById(id).get();
}
public Person createPerson (Person person){
return repository.save(person);
}
public Person updatePerson (Person person) {
// Person personInDB = repository.findOne(person.getId());
// personInDB.setFirstName(person.getFirstName());
// personInDB.setLastName(person.getLastName());
// return repository.save(personInDB);
return repository.save(person);
}
public Boolean deletePerson (Integer id) {
repository.deleteById(id);
return true;
}
}