From 148b6c6db02d456f2773284da5451ee35fff9e15 Mon Sep 17 00:00:00 2001 From: kgc91747 Date: Mon, 12 Aug 2024 10:10:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=80=B4=EC=A6=88=20=EC=8B=9C=EC=9E=91?= =?UTF-8?q?=EC=9D=B4=ED=9B=84=20=20=ED=95=B4=EB=8B=B9=20=ED=80=B4=EC=A6=88?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EB=B6=88=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edufocus/quiz/service/QuizSetService.java | 2 +- .../edufocus/quiz/service/QuizSetServiceImpl.java | 10 ++-------- .../edufocus/ws/controller/ChatController.java | 12 ++++++++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java index 97e75d2..8a610cc 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetService.java @@ -22,5 +22,5 @@ public interface QuizSetService { List findMyQuizSetResponses(long userId); - void updateQuizSetTested(long quizSetId, long userId, boolean tested); + void updateQuizSetTested(long quizSetId); } diff --git a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java index a636f0c..07b68a3 100644 --- a/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/quiz/service/QuizSetServiceImpl.java @@ -99,15 +99,9 @@ public class QuizSetServiceImpl implements QuizSetService { } @Override - public void updateQuizSetTested(long quizSetId, long userId, boolean tested) { + public void updateQuizSetTested(long quizSetId) { QuizSet quizSet = quizSetRepository.findById(quizSetId).orElseThrow(NoSuchElementException::new); - - User user = userRepository.findById(userId).orElseThrow(NoSuchElementException::new); - - if (quizSet.getUser().getId() != user.getId()) { - throw new UnAuthorizedException(); - } - + quizSet.setTested(true); quizSetRepository.save(quizSet); } diff --git a/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java b/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java index 4e280b9..6f149f0 100644 --- a/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java +++ b/backend/src/main/java/com/edufocus/edufocus/ws/controller/ChatController.java @@ -2,6 +2,7 @@ package com.edufocus.edufocus.ws.controller; import com.edufocus.edufocus.global.constant.RabbitMQConstant; +import com.edufocus.edufocus.quiz.service.QuizSetService; import com.edufocus.edufocus.report.service.ReportService; import com.edufocus.edufocus.ws.entity.dto.MessageDto; import com.edufocus.edufocus.ws.entity.dto.QuizDto; @@ -17,22 +18,25 @@ public class ChatController { RabbitTemplate rabbitTemplate; ReportService reportService; + QuizSetService quizSetService; - public ChatController(RabbitTemplate rabbitTemplate, ReportService reportService){ + public ChatController(RabbitTemplate rabbitTemplate, ReportService reportService, QuizSetService quizSetService) { this.rabbitTemplate = rabbitTemplate; this.reportService = reportService; + this.quizSetService = quizSetService; } @MessageMapping("chat.message.{lectureId}") - public void sendMessage(@DestinationVariable long lectureId, MessageDto messageDto){ - rabbitTemplate.convertAndSend(RabbitMQConstant.CHAT_EXCHANGE.getConstant(), + public void sendMessage(@DestinationVariable long lectureId, MessageDto messageDto) { + rabbitTemplate.convertAndSend(RabbitMQConstant.CHAT_EXCHANGE.getConstant(), RabbitMQConstant.ROUTING_KEY_PREFIX.getConstant() + lectureId, messageDto); } @MessageMapping("chat.quiz.{lectureId}") - public void quizStart(@DestinationVariable long lectureId, QuizDto quizDto){ + public void quizStart(@DestinationVariable long lectureId, QuizDto quizDto) { UUID reportSetId = reportService.initReportSet(lectureId, quizDto.getQuizSetId()); + quizSetService.updateQuizSetTested(quizDto.getQuizSetId()); quizDto.setReportSetId(reportSetId);