Merge branch 'backend' of https://lab.ssafy.com/s11-webmobile1-sub2/S11P12A701 into be/Quiz
This commit is contained in:
commit
525166776d
@ -29,7 +29,9 @@ public interface LectureService {
|
||||
|
||||
Lecture findLectureByTitle(String title);
|
||||
|
||||
void changeState(Long lectureId);
|
||||
void startClass(Long lectureId);
|
||||
|
||||
void stopClass(Long lectureId);
|
||||
|
||||
boolean getState(Long lectureId);
|
||||
|
||||
|
@ -225,7 +225,7 @@ public class LectureServiceImpl implements LectureService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeState(Long id) {
|
||||
public void startClass(Long id) {
|
||||
|
||||
Optional<Lecture> lecture = lectureRepository.findById(id);
|
||||
|
||||
@ -245,6 +245,26 @@ public class LectureServiceImpl implements LectureService {
|
||||
lectureRepository.save(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopClass(Long id) {
|
||||
Optional<Lecture> lecture = lectureRepository.findById(id);
|
||||
|
||||
|
||||
if (!lecture.isPresent()) {
|
||||
throw new RuntimeException("Lecture not found with id: " + id);
|
||||
|
||||
}
|
||||
|
||||
Lecture l;
|
||||
l = lecture.get();
|
||||
if (l.isOnline()) {
|
||||
l.setOnline(false);
|
||||
}
|
||||
|
||||
|
||||
lectureRepository.save(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getState(Long lectureId) {
|
||||
|
||||
|
@ -136,6 +136,26 @@ public class Controller {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/deleteroom/{lecture_id}")
|
||||
public ResponseEntity<Map<String, String>> deleteRooom(@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);
|
||||
if (findUser.getRole() == UserRole.ADMIN) {
|
||||
|
||||
|
||||
videoSertvice.startOnline(userId, id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", " "));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/livekit/webhook", consumes = "application/webhook+json")
|
||||
public ResponseEntity<String> receiveWebhook(@RequestHeader("Authorization") String authHeader, @RequestBody String body) {
|
||||
WebhookReceiver webhookReceiver = new WebhookReceiver(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||
|
@ -24,12 +24,12 @@ public class VideoServiceImpl implements VideoSertvice {
|
||||
@Override
|
||||
public void startOnline(Long userId, Long lectureId) throws SQLException {
|
||||
|
||||
lectureService.changeState(lectureId);
|
||||
lectureService.startClass(lectureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopOnline(Long userId, Long lectureId) throws SQLException {
|
||||
lectureService.changeState(lectureId);
|
||||
lectureService.startClass(lectureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user