feat: Quiz 강사/학생 타입별 퀴즈 조회 결과 구분

This commit is contained in:
kgc91747 2024-08-02 16:18:17 +09:00
parent 176a68dfb8
commit 44e9308927

View File

@ -42,13 +42,25 @@ public class QuizController {
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }
@GetMapping("/{quizsetId}") @GetMapping("/student/{quizsetId}")
public ResponseEntity<?> getQuizzes(@PathVariable Long quizsetId) { public ResponseEntity<?> getQuizzes(@PathVariable Long quizsetId) {
QuizSetResponse quizSet = quizSetService.findQuizSetResponse(quizsetId); QuizSetResponse quizSet = quizSetService.findQuizSetResponse(quizsetId);
return new ResponseEntity<>(quizSet, HttpStatus.OK); return new ResponseEntity<>(quizSet, HttpStatus.OK);
} }
@GetMapping("/teacher/{quizsetId}")
public ResponseEntity<?> getQuizzesIncludeAnswer(@RequestHeader("Authorization") String accessToken, @PathVariable Long quizsetId) {
long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
QuizSet quizSet = quizSetService.findQuizSet(quizsetId);
if (quizSet.getUser().getId() != userId) {
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
return new ResponseEntity<>(quizSet, HttpStatus.OK);
}
@DeleteMapping("/{quizsetId}") @DeleteMapping("/{quizsetId}")
public ResponseEntity<?> deleteQuizSet(@RequestHeader("Authorization") String accessToken, @PathVariable long quizsetId) { public ResponseEntity<?> deleteQuizSet(@RequestHeader("Authorization") String accessToken, @PathVariable long quizsetId) {
long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); long userId = Long.parseLong(jwtUtil.getUserId(accessToken));