Skip to content

Commit 9a7a500

Browse files
authored
Merge pull request #32 from CodeURJC-DAW-2021-22/HotFix_api_report
Hot fix api report to develop
2 parents 44162d3 + 89bc3da commit 9a7a500

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

backend/src/main/java/es/codeurjc/wallypop/controller/api/ReportRestController.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.springframework.web.bind.annotation.*;
1515

1616
import es.codeurjc.wallypop.model.Report;
17+
import es.codeurjc.wallypop.service.ArticleService;
1718
import es.codeurjc.wallypop.service.ReportService;
1819
import org.springframework.web.multipart.MultipartFile;
1920

@@ -25,12 +26,15 @@ public class ReportRestController {
2526

2627
@Autowired
2728
private ReportService reportService;
28-
29-
@PostMapping("")
29+
@Autowired
30+
private ArticleService articleService;
31+
32+
@PostMapping("/{idArticle}")
3033
@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);
3438
}
3539

3640
@PostMapping("/{idReport}/image")

backend/src/main/java/es/codeurjc/wallypop/model/Report.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@Entity
2222
@Table(name = "REPORT")
2323
//@JsonIdentityInfo(generator= ObjectIdGenerators.IntSequenceGenerator.class, property="@id_report")
24-
@JsonIgnoreProperties(value = "article")
24+
//@JsonIgnoreProperties(value = "article")
2525
public class Report {
2626

2727
@Id

0 commit comments

Comments
 (0)