-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDemoService.java
More file actions
33 lines (26 loc) · 923 Bytes
/
DemoService.java
File metadata and controls
33 lines (26 loc) · 923 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
package com.codejam.demo.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.codejam.demo.model.PersonalInfo;
import com.codejam.demo.repository.PersonalInfoRepository;
@Service
public class DemoService {
@Autowired
PersonalInfoRepository personalInfoRepository;
public List<PersonalInfo> getAllPersonalInfo() {
List<PersonalInfo> personalInfos = new ArrayList<PersonalInfo>();
personalInfoRepository.findAll().forEach(personalInfo -> personalInfos.add(personalInfo));
return personalInfos;
}
public PersonalInfo getPersonalInfoById(int id) {
return personalInfoRepository.findById(id).get();
}
public void saveOrUpdate(PersonalInfo personalInfo) {
personalInfoRepository.save(personalInfo);
}
public void delete(int id) {
personalInfoRepository.deleteById(id);
}
}