feat: 퀴즈 시작이후 해당 퀴즈 변경 불가

This commit is contained in:
kgc91747 2024-08-12 10:10:33 +09:00
parent 9930da9acc
commit 148b6c6db0
3 changed files with 11 additions and 13 deletions

View File

@ -22,5 +22,5 @@ public interface QuizSetService {
List<MyQuizSetResponse> findMyQuizSetResponses(long userId);
void updateQuizSetTested(long quizSetId, long userId, boolean tested);
void updateQuizSetTested(long quizSetId);
}

View File

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

View File

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