File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
backend/src/main/java/es/codeurjc/wallypop Expand file tree Collapse file tree 2 files changed +10
-6
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,15 @@ 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
+ report .setARTICLE (articleService .findById (idArticle ).get ());
36
+ reportService .save (report );
37
+ return new ResponseEntity <>(report , HttpStatus .OK );
34
38
}
35
39
36
40
@ PostMapping ("/{idReport}/image" )
Original file line number Diff line number Diff line change 21
21
@ Entity
22
22
@ Table (name = "REPORT" )
23
23
//@JsonIdentityInfo(generator= ObjectIdGenerators.IntSequenceGenerator.class, property="@id_report")
24
- @ JsonIgnoreProperties (value = "article" )
24
+ // @JsonIgnoreProperties(value = "article")
25
25
public class Report {
26
26
27
27
@ Id
You can’t perform that action at this time.
0 commit comments