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
import service.student.studentaddressservice.model.StudentAddress;
import service.student.studentaddressservice.service.StudentAddressService;
import java.util.List;
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/api/v1")
......@@ -16,6 +18,12 @@ public class StudentAddressController {
@Autowired
StudentAddressService studentAddressService;
@GetMapping("/studentaddress")
public List<StudentAddress> getAllStudentAddress() {
List<StudentAddress> studentAddresses = studentAddressService.getAllStudentAddress();
return studentAddresses;
}
@GetMapping("/studentaddress/{email}")
public ResponseEntity<StudentAddress> getStudentAddress(@PathVariable("email") String email) throws
ResourceNotFoundException {
......
......@@ -10,6 +10,7 @@ import service.student.studentaddressservice.exception.ResourceNotFoundException
import service.student.studentaddressservice.model.StudentAddress;
import service.student.studentaddressservice.repository.StudentAddressRepository;
import java.util.List;
import java.util.Optional;
@Service
......@@ -43,4 +44,9 @@ public class StudentAddressService {
}
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