From 6a6852b4f53aad184080ecd3756f6f129c8e337a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=A0=95=EB=AF=BC?= Date: Mon, 5 Aug 2024 16:07:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=96=B4=EB=93=9C=EB=AF=BC,=ED=95=99?= =?UTF-8?q?=EC=83=9D=20=EB=B0=A9=20=EC=9E=85=EC=9E=A5=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../quiz/controller/QuizController.java | 2 +- .../report/service/ReportServiceImpl.java | 26 +++++------ .../user/config/WebConfiguration.java | 10 ++-- .../edufocus/video/controller/Controller.java | 46 +++++++------------ 4 files changed, 36 insertions(+), 48 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java b/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java index c85822a..8edb05e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/controller/QuizController.java @@ -28,7 +28,7 @@ public class QuizController { private final JWTUtil jwtUtil; @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity createQuizSet(@RequestHeader("Authorization") String accessToken, @RequestPart QuizSetCreateRequest quizSetCreateRequest + public ResponseEntity createQuizSet(@RequestHeader("Authzation") String accessToken, @RequestPart QuizSetCreateRequest quizSetCreateRequest , @RequestPart(value = "images", required = false) List images) throws IOException { long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); diff --git a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java index 104e626..a9e119e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java @@ -41,34 +41,33 @@ public class ReportServiceImpl implements ReportService { QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId()); - + System.out.println(quizSet.toString()); List quizList = quizSet.getQuizzes(); List answerInputList = reportRequset.getAnswerInputList(); Report report = new Report(); Long reportNum = report.getId(); - int allCount= quizList.size(); - int correctCount =0 ; + int allCount = quizList.size(); + int correctCount = 0; - User testuser= userRepository.findById(reportRequset.getUserId()).orElse(null); + User testuser = userRepository.findById(reportRequset.getUserId()).orElse(null); for (Quiz quiz : quizList) { for (AnswerInput answerInput : answerInputList) { if (quiz.getId() == answerInput.getAnswerinputID()) { - if(quiz.getAnswer().equals(answerInput.getAnswer())) { + if (quiz.getAnswer().equals(answerInput.getAnswer())) { correctCount++; Answer answer = Answer.builder() - .userAnswer(answerInput.getAnswer()) + .userAnswer(answerInput.getAnswer()) .isCorrect(true) .report(report) .quiz(quiz) .build(); - } - else{ + } else { Answer answer = Answer.builder() .userAnswer(answerInput.getAnswer()) .isCorrect(false) @@ -77,7 +76,6 @@ public class ReportServiceImpl implements ReportService { .build(); - } } @@ -86,11 +84,11 @@ public class ReportServiceImpl implements ReportService { } report = Report.builder() - .user(testuser) - .quizSet(quizSet) - .allCount(allCount) - .correctCount(correctCount) - .testAt(new Date()).build(); + .user(testuser) + .quizSet(quizSet) + .allCount(allCount) + .correctCount(correctCount) + .testAt(new Date()).build(); ReportResponse reportResponse = ReportResponse.builder() .quizesetId(quizSet.getId()) .userId(testuser.getId()) diff --git a/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java b/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java index 0d8851c..0972d21 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/config/WebConfiguration.java @@ -21,13 +21,14 @@ public class WebConfiguration implements WebMvcConfigurer { this.jwtInterceptor = jwtInterceptor; } -// + + // @Override public void addCorsMappings(CorsRegistry registry) { registry .addMapping("/**") - .allowedOriginPatterns("https://i11a701.p.ssafy.io/","https://localhost:5173", "http://localhost:5173", "http://localhost:4173","http://localhost:5080","http://192.168.*.*:5173") - .allowedMethods("GET","POST",HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), + .allowedOriginPatterns("https://i11a701.p.ssafy.io/", "https://localhost:5173", "http://localhost:5173", "http://localhost:4173", "http://localhost:5080", "http://192.168.*.*:5173") + .allowedMethods("GET", "POST", HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.DELETE.name(), HttpMethod.HEAD.name(), HttpMethod.OPTIONS.name(), HttpMethod.PATCH.name()) .allowCredentials(true) @@ -41,10 +42,11 @@ public class WebConfiguration implements WebMvcConfigurer { registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/assets/img/"); registry.addResourceHandler("/*.html**").addResourceLocations("classpath:/static/"); } + @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(jwtInterceptor) .addPathPatterns("/**") // 모든 경로에 대해 인터셉터 적용 - .excludePathPatterns("/v3/api-docs/**","/swagger-resources/**","/webjars/**","/swagger-ui/**","/auth/**", "/board/**", "/user/**","/lecture/**","/qna/**", "/quiz/**","/video/**","/registration/**"); // 인증 없이 접근 가능한 경로 설정 + .excludePathPatterns("/v3/api-docs/**", "/swagger-resources/**", "/webjars/**", "/swagger-ui/**", "/auth/**", "/board/**", "/user/**", "/lecture/**", "/qna/**", "/quiz/**", "/video/**", "/registration/**", "/report/**"); // 인증 없이 접근 가능한 경로 설정 } } \ No newline at end of file diff --git a/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java b/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java index 6bfa21a..6dbba66 100644 --- a/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java +++ b/backend/src/main/java/com/edufocus/edufocus/video/controller/Controller.java @@ -93,36 +93,9 @@ public class Controller { } - } + } else if (findUser.getRole() == UserRole.ADMIN) {//&& lecture.isOnline() ) { - return ResponseEntity.ok(Map.of("token", null)); - - } - - - @PostMapping(value = "/makeroom/{lecture_id}") - public ResponseEntity> makeRoom(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception { - String userToken = request.getHeader("Authorization"); - - - Long userId = Long.parseLong(jwtUtil.getUserId(userToken)); - User findUser = userRepository.findById(userId).orElse(null); - Lecture lecture = lectureRepository.findById(id).orElse(null); - - - String roomName = lecture.getTitle(); - String participantName = userService.getUserName(userId); - System.out.println(participantName); - - AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET); - - - if (findUser.getRole() == UserRole.ADMIN) {//&& lecture.isOnline() ) { - - - videoSertvice.startOnline(userId, id); - IdentityData identityData = new IdentityData(participantName, "강사"); String jsonIdentity = serializeIdentityData(identityData); @@ -137,11 +110,26 @@ public class Controller { } - return ResponseEntity.ok(Map.of("token", null)); } + + @PostMapping(value = "/makeroom/{lecture_id}") + public ResponseEntity> makeRoom(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception { + String userToken = request.getHeader("Authorization"); + + + Long userId = Long.parseLong(jwtUtil.getUserId(userToken)); + + + videoSertvice.startOnline(userId, id); + + + return ResponseEntity.ok(Map.of("token", " ")); + + } + @PostMapping(value = "/livekit/webhook", consumes = "application/webhook+json") public ResponseEntity receiveWebhook(@RequestHeader("Authorization") String authHeader, @RequestBody String body) { WebhookReceiver webhookReceiver = new WebhookReceiver(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);