Commit 91c87880 authored by dbhuller's avatar dbhuller

adding route and service to get all student addresses

parent 892cce3e
...@@ -8,6 +8,8 @@ import service.student.studentaddressservice.exception.ResourceNotFoundException ...@@ -8,6 +8,8 @@ import service.student.studentaddressservice.exception.ResourceNotFoundException
import service.student.studentaddressservice.model.StudentAddress; import service.student.studentaddressservice.model.StudentAddress;
import service.student.studentaddressservice.service.StudentAddressService; import service.student.studentaddressservice.service.StudentAddressService;
import java.util.List;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@RestController @RestController
@RequestMapping("/api/v1") @RequestMapping("/api/v1")
...@@ -16,6 +18,12 @@ public class StudentAddressController { ...@@ -16,6 +18,12 @@ public class StudentAddressController {
@Autowired @Autowired
StudentAddressService studentAddressService; StudentAddressService studentAddressService;
@GetMapping("/studentaddress")
public List<StudentAddress> getAllStudentAddress() {
List<StudentAddress> studentAddresses = studentAddressService.getAllStudentAddress();
return studentAddresses;
}
@GetMapping("/studentaddress/{email}") @GetMapping("/studentaddress/{email}")
public ResponseEntity<StudentAddress> getStudentAddress(@PathVariable("email") String email) throws public ResponseEntity<StudentAddress> getStudentAddress(@PathVariable("email") String email) throws
ResourceNotFoundException { ResourceNotFoundException {
......
...@@ -10,6 +10,7 @@ import service.student.studentaddressservice.exception.ResourceNotFoundException ...@@ -10,6 +10,7 @@ import service.student.studentaddressservice.exception.ResourceNotFoundException
import service.student.studentaddressservice.model.StudentAddress; import service.student.studentaddressservice.model.StudentAddress;
import service.student.studentaddressservice.repository.StudentAddressRepository; import service.student.studentaddressservice.repository.StudentAddressRepository;
import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
...@@ -43,4 +44,9 @@ public class StudentAddressService { ...@@ -43,4 +44,9 @@ public class StudentAddressService {
} }
return studentAddressRepository.save(studentAddressToUpdate); return studentAddressRepository.save(studentAddressToUpdate);
} }
public List<StudentAddress> getAllStudentAddress() {
List<StudentAddress> studentAddressList = studentAddressRepository.findAll();
return studentAddressList;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment