File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
backend/src/main/java/es/codeurjc/wallypop/controller/api Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 14
14
import org .springframework .web .bind .annotation .*;
15
15
16
16
import es .codeurjc .wallypop .model .Report ;
17
+ import es .codeurjc .wallypop .service .ArticleService ;
17
18
import es .codeurjc .wallypop .service .ReportService ;
18
19
import org .springframework .web .multipart .MultipartFile ;
19
20
@@ -25,12 +26,16 @@ public class ReportRestController {
25
26
26
27
@ Autowired
27
28
private ReportService reportService ;
28
-
29
- @ PostMapping ("" )
29
+ @ Autowired
30
+ private ArticleService articleService ;
31
+
32
+ @ PostMapping ("/{idArticle}" )
30
33
@ ResponseStatus (HttpStatus .CREATED )
31
- public ResponseEntity <Report > createReport (@ RequestBody Report report ) {
32
- reportService .save (report );
33
- return new ResponseEntity <>(report , HttpStatus .OK );
34
+ public ResponseEntity <Report > createReport (@ PathVariable long idArticle ,@ RequestBody Report report ) {
35
+ reportService .save (report );
36
+ reportService .findById (report .getID_REPORT ()).get ().setARTICLE (articleService .findById (idArticle ).get ());
37
+ reportService .flush ();
38
+ return new ResponseEntity <>(report , HttpStatus .OK );
34
39
}
35
40
36
41
@ PostMapping ("/{idReport}/image" )
You can’t perform that action at this time.
0 commit comments