-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrivateCursoController.java
More file actions
34 lines (28 loc) · 1.24 KB
/
PrivateCursoController.java
File metadata and controls
34 lines (28 loc) · 1.24 KB
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
34
package br.com.openenade.api.curso;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import br.com.openenade.api.modalidade.ModalidadeService;
@RestController
@RequestMapping(path = PublicCursoController.ENDPOINT)
public class PrivateCursoController {
@Autowired
private CursoService service;
@ResponseBody
@PostMapping
public Curso addCurso(@Valid @RequestBody Curso newCurso) {
return this.service.addCurso(newCurso);
}
@DeleteMapping(path = "/{codigo}/{modalidade}")
public void deleteCursoByCodigo(@PathVariable(name = "codigo") Long codigo,
@PathVariable(name = "modalidade") Integer modalidadeId) {
this.service
.deleteById(new CursoId(codigo, ModalidadeService.getModalidadeById(modalidadeId)));
}
}