Skip to content
Snippets Groups Projects

added more fields to the trivio entity

Merged Tini Tran requested to merge rest-endpoints into main
6 files
+ 188
0
Compare changes
  • Side-by-side
  • Inline
Files
6
package ntnu.idatt2105.group44.trivioServer.controller;
import ntnu.idatt2105.group44.trivioServer.dto.ResultDTO;
import ntnu.idatt2105.group44.trivioServer.model.Result;
import ntnu.idatt2105.group44.trivioServer.repository.ResultRepository;
import ntnu.idatt2105.group44.trivioServer.service.ResultService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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("results")
public class ResultController {
private final ResultService resultService;
public ResultController(ResultService resultService){
this.resultService = resultService;
}
@GetMapping(path = "{userId}")
public Result getResultByUserId(@PathVariable Long userId){
return resultService.getResultbyId(userId);
}
// test det senere
@PostMapping
public ResponseEntity<String> postResult(@RequestBody ResultDTO resultDTO){
resultService.addResult(resultDTO);
return new ResponseEntity<>(HttpStatus.OK);
}
}
Loading