source: Git/src/main/java/com/wediscussmovies/project/web/controller/rest/PersonRestController.java@ 5b447b0

main
Last change on this file since 5b447b0 was 5b447b0, checked in by Test <matonikolov77@…>, 2 years ago

Adding models and resources

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package com.wediscussmovies.project.web.controller.rest;
2
3import com.wediscussmovies.project.LoggedUser;
4import com.wediscussmovies.project.ajaxmodels.Grade;
5import com.wediscussmovies.project.service.PersonService;
6import org.springframework.http.ResponseEntity;
7import org.springframework.web.bind.annotation.*;
8
9@RestController
10@RequestMapping("/api/persons")
11public class PersonRestController {
12
13 private final PersonService personService;
14
15 public PersonRestController(PersonService personService) {
16 this.personService = personService;
17 }
18
19 @DeleteMapping("/delete/{id}")
20 public ResponseEntity deletePerson(@PathVariable Integer id){
21
22 try {
23 this.personService.deleteById(id);
24 return ResponseEntity.ok(true);
25 }
26 catch (RuntimeException exception){
27 return ResponseEntity.ok(false);
28 }
29 }
30 @PostMapping("/grade/{personId}")
31 public ResponseEntity addGrade(@PathVariable Integer personId, @RequestBody Grade grade){
32 try {
33 this.personService.addGradePerson(personId, LoggedUser.getLoggedUser(),grade);
34 return ResponseEntity.ok(true);
35 }
36 catch (RuntimeException exception){
37 return ResponseEntity.ok(false);
38 }
39
40 }
41}
Note: See TracBrowser for help on using the repository browser.