Merge branch 'be/Quiz' into 'backend'

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

See merge request s11-webmobile1-sub2/S11P12A701!29
This commit is contained in:
김한얼 2024-08-05 10:25:50 +09:00
commit a4b0275956

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));