File tree Expand file tree Collapse file tree
src/main/java/ac/simons/netbeansevening Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package ac .simons .netbeansevening ;
2+
3+ import javax .validation .Valid ;
4+
5+ import org .springframework .web .bind .annotation .PathVariable ;
6+ import org .springframework .web .bind .annotation .RequestBody ;
7+ import org .springframework .web .bind .annotation .RequestMapping ;
8+ import org .springframework .web .bind .annotation .RestController ;
9+
10+ import static org .springframework .web .bind .annotation .RequestMethod .GET ;
11+ import static org .springframework .web .bind .annotation .RequestMethod .POST ;
12+
13+ @ RestController
14+ @ RequestMapping ("/registrations" )
15+ public class RegistrationController {
16+
17+ private final RegistrationRepository registrationRepository ;
18+
19+ public RegistrationController (RegistrationRepository registrationRepository ) {
20+ this .registrationRepository = registrationRepository ;
21+ }
22+
23+ @ RequestMapping (method = GET )
24+ public Iterable <RegistrationEntity > list () {
25+ return this .registrationRepository .findAll ();
26+ }
27+
28+ @ RequestMapping (value = "/{id}" , method = GET )
29+ public RegistrationEntity get (@ PathVariable Integer id ) {
30+ return this .registrationRepository .findOne (id );
31+ }
32+
33+ @ RequestMapping (method = POST )
34+ public RegistrationEntity create (@ Valid @ RequestBody RegistrationEntity newRegistration ) {
35+ return this .registrationRepository .save (newRegistration );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments