Class ReportingController
java.lang.Object
com.markvarga21.studentmanager.controller.ReportingController
@RestController
@RequestMapping("/api/v1/report")
@CrossOrigin
public class ReportingController
extends Object
A controller which is used to handle user reports/feedback.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<String>
deleteReport
(Long id) Deletes a report by its id.org.springframework.data.domain.Page<Report>
getReports
(Integer page, Integer size) Retrieves all the reports.org.springframework.http.ResponseEntity<String>
sendReport
(ReportMessage reportMessage) Submits a report.
-
Constructor Details
-
ReportingController
public ReportingController()
-
-
Method Details
-
getReports
@GetMapping @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.data.domain.Page<Report> getReports(@RequestParam(defaultValue="0") Integer page, @RequestParam(defaultValue="10") Integer size) Retrieves all the reports.- Parameters:
page
- The page number.size
- The number of elements in a single page.- Returns:
- A page containing the reports.
-
deleteReport
@DeleteMapping("/{id}") @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<String> deleteReport(@PathVariable Long id) Deletes a report by its id.- Parameters:
id
- The id of the report.- Returns:
- An informational message.
-
sendReport
@PostMapping @PreAuthorize("hasRole(\'ROLE_USER\')") public org.springframework.http.ResponseEntity<String> sendReport(@RequestBody @Validated ReportMessage reportMessage) throws jakarta.mail.MessagingException Submits a report.- Parameters:
reportMessage
- The message of the report.- Returns:
- An informational message.
- Throws:
jakarta.mail.MessagingException
-