feat: 어드민,학생 방 입장 로직 변경

This commit is contained in:
박정민 2024-08-05 16:07:37 +09:00
parent e0dcdee366
commit 6a6852b4f5
4 changed files with 36 additions and 48 deletions

View File

@ -28,7 +28,7 @@ public class QuizController {
private final JWTUtil jwtUtil; private final JWTUtil jwtUtil;
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @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<MultipartFile> images) throws IOException { , @RequestPart(value = "images", required = false) List<MultipartFile> images) throws IOException {
long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); long userId = Long.parseLong(jwtUtil.getUserId(accessToken));

View File

@ -41,7 +41,7 @@ public class ReportServiceImpl implements ReportService {
QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId()); QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId());
System.out.println(quizSet.toString());
List<Quiz> quizList = quizSet.getQuizzes(); List<Quiz> quizList = quizSet.getQuizzes();
List<AnswerInput> answerInputList = reportRequset.getAnswerInputList(); List<AnswerInput> answerInputList = reportRequset.getAnswerInputList();
@ -67,8 +67,7 @@ public class ReportServiceImpl implements ReportService {
.quiz(quiz) .quiz(quiz)
.build(); .build();
} } else {
else{
Answer answer = Answer.builder() Answer answer = Answer.builder()
.userAnswer(answerInput.getAnswer()) .userAnswer(answerInput.getAnswer())
.isCorrect(false) .isCorrect(false)
@ -77,7 +76,6 @@ public class ReportServiceImpl implements ReportService {
.build(); .build();
} }
} }

View File

@ -21,6 +21,7 @@ public class WebConfiguration implements WebMvcConfigurer {
this.jwtInterceptor = jwtInterceptor; this.jwtInterceptor = jwtInterceptor;
} }
// //
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
@ -41,10 +42,11 @@ public class WebConfiguration implements WebMvcConfigurer {
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/assets/img/"); registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/assets/img/");
registry.addResourceHandler("/*.html**").addResourceLocations("classpath:/static/"); registry.addResourceHandler("/*.html**").addResourceLocations("classpath:/static/");
} }
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(jwtInterceptor) registry.addInterceptor(jwtInterceptor)
.addPathPatterns("/**") // 모든 경로에 대해 인터셉터 적용 .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/**"); // 인증 없이 접근 가능한 경로 설정
} }
} }

View File

@ -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<Map<String, String>> 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, "강사"); IdentityData identityData = new IdentityData(participantName, "강사");
String jsonIdentity = serializeIdentityData(identityData); String jsonIdentity = serializeIdentityData(identityData);
@ -137,11 +110,26 @@ public class Controller {
} }
return ResponseEntity.ok(Map.of("token", null)); return ResponseEntity.ok(Map.of("token", null));
} }
@PostMapping(value = "/makeroom/{lecture_id}")
public ResponseEntity<Map<String, String>> 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") @PostMapping(value = "/livekit/webhook", consumes = "application/webhook+json")
public ResponseEntity<String> receiveWebhook(@RequestHeader("Authorization") String authHeader, @RequestBody String body) { public ResponseEntity<String> receiveWebhook(@RequestHeader("Authorization") String authHeader, @RequestBody String body) {
WebhookReceiver webhookReceiver = new WebhookReceiver(LIVEKIT_API_KEY, LIVEKIT_API_SECRET); WebhookReceiver webhookReceiver = new WebhookReceiver(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);