diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-07-23 15:25:17 +1000 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-07-23 15:25:17 +1000 |
| commit | aec0dff5477cafce865410381a722fedbac04ac1 (patch) | |
| tree | 532bd7a41e9c97e1df53cf122888a77a2f7a9f00 /src/main/java/com/stileeducation/markr/controller/TestResultsController.java | |
| parent | fc96ec673822d9f1cbe0e5eb004c12b7f8f2db9b (diff) | |
Implement simple /import endpoint and test
Diffstat (limited to 'src/main/java/com/stileeducation/markr/controller/TestResultsController.java')
| -rw-r--r-- | src/main/java/com/stileeducation/markr/controller/TestResultsController.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/com/stileeducation/markr/controller/TestResultsController.java b/src/main/java/com/stileeducation/markr/controller/TestResultsController.java new file mode 100644 index 0000000..b1a5e63 --- /dev/null +++ b/src/main/java/com/stileeducation/markr/controller/TestResultsController.java @@ -0,0 +1,32 @@ +package com.stileeducation.markr.controller; + +import com.stileeducation.markr.dto.MCQTestResultsDTO; +import com.stileeducation.markr.service.TestResultsService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.RestController; + +@RestController +@RequestMapping("/") +public class TestResultsController { + + public static final String IMPORT_ENDPOINT = "/import"; + + private final TestResultsService testResultsService; + + public TestResultsController(TestResultsService testResultsService) { + this.testResultsService = testResultsService; + } + + // TODO - update to consume text/xml+markr, consider return value + @PostMapping(value = IMPORT_ENDPOINT, consumes = "application/xml", produces = "application/json") + public ResponseEntity<Void> handleXmlRequest(@RequestBody MCQTestResultsDTO testResults) { + testResultsService.importTestResults(testResults); + + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + +} |
