merge backend
This commit is contained in:
commit
e224f0096b
@ -129,7 +129,7 @@ public class BoardController {
|
||||
|
||||
|
||||
@ExceptionHandler()
|
||||
public ResponseEntity<?> NoContentException(Exception exception){
|
||||
public ResponseEntity<?> NoContentException(Exception e){
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package com.edufocus.edufocus.board.entity.vo;
|
||||
import com.edufocus.edufocus.board.entity.dto.ResponseBoardDetailDto;
|
||||
import com.edufocus.edufocus.board.entity.dto.ResponseBoardSummaryDto;
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
@ -13,7 +13,6 @@ import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
|
@ -2,7 +2,7 @@ package com.edufocus.edufocus.board.entity.vo;
|
||||
|
||||
|
||||
import com.edufocus.edufocus.board.entity.dto.ResponseCommentDto;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -8,7 +8,7 @@ import com.edufocus.edufocus.board.repository.BoardRepository;
|
||||
import com.edufocus.edufocus.board.repository.CommentRepository;
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.lecture.repository.LectureRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@ -72,7 +72,7 @@ public class BoardServiceImpl implements BoardService {
|
||||
|
||||
@Transactional
|
||||
public void updateBoard(long boardId, RequestBoardUpdateDto requestBoardUpdateDto) {
|
||||
Board board = boardRepository.findById(boardId).orElseThrow(IllegalArgumentException::new);
|
||||
Board board = boardRepository.getReferenceById(boardId);
|
||||
|
||||
board.setTitle(requestBoardUpdateDto.getTitle());
|
||||
board.setContent(requestBoardUpdateDto.getContent());
|
||||
@ -113,7 +113,7 @@ public class BoardServiceImpl implements BoardService {
|
||||
|
||||
@Transactional
|
||||
public void updateComment(long commentId, RequestCommentDto requestCommentDto) {
|
||||
Comment comment = commentRepository.findById(commentId).orElseThrow(IllegalArgumentException::new);
|
||||
Comment comment = commentRepository.getReferenceById(commentId);
|
||||
|
||||
comment.setContent(requestCommentDto.getContent());
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.edufocus.edufocus.lecture.entity;
|
||||
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
|
@ -6,8 +6,8 @@ import com.edufocus.edufocus.lecture.repository.LectureRepository;
|
||||
import com.edufocus.edufocus.registration.entity.Registration;
|
||||
import com.edufocus.edufocus.registration.entity.RegistrationStatus;
|
||||
import com.edufocus.edufocus.registration.repository.RegistrationRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.UserRole;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.UserRole;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -235,8 +235,14 @@ public class LectureServiceImpl implements LectureService {
|
||||
|
||||
Lecture l;
|
||||
l = lecture.get();
|
||||
l.setOnline(true);
|
||||
|
||||
if(l.isOnline())
|
||||
{
|
||||
l.setOnline(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
l.setOnline(true);
|
||||
}
|
||||
|
||||
|
||||
lectureRepository.save(l);
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.edufocus.edufocus.qna.entity;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -6,19 +6,16 @@ import com.edufocus.edufocus.qna.entity.Qna;
|
||||
import com.edufocus.edufocus.qna.entity.QnaRequestDto;
|
||||
import com.edufocus.edufocus.qna.entity.QnaResponseDto;
|
||||
import com.edufocus.edufocus.qna.repository.QnaRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.edufocus.edufocus.quiz.entity;
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
|
@ -2,7 +2,7 @@ package com.edufocus.edufocus.quiz.service;
|
||||
|
||||
import com.edufocus.edufocus.quiz.entity.*;
|
||||
import com.edufocus.edufocus.quiz.repository.QuizSetRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.edufocus.edufocus.registration.entity;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.edufocus.edufocus.registration.service;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.lecture.repository.LectureRepository;
|
||||
import com.edufocus.edufocus.registration.entity.Registration;
|
||||
import com.edufocus.edufocus.registration.entity.RegistrationSearchResponse;
|
||||
import com.edufocus.edufocus.registration.entity.RegistrationStatus;
|
||||
import com.edufocus.edufocus.registration.repository.RegistrationRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.UserRole;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.UserRole;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.edufocus.edufocus.report.entity.vo;
|
||||
|
||||
import com.edufocus.edufocus.quiz.entity.QuizSet;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.edufocus.edufocus.report.entity.dto.AnswerInput;
|
||||
import com.edufocus.edufocus.report.entity.vo.Report;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
|
||||
import com.edufocus.edufocus.report.repository.ReportRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -1,12 +1,10 @@
|
||||
package com.edufocus.edufocus.user.controller;
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.InfoDto;
|
||||
import com.edufocus.edufocus.user.model.entity.PasswordDto;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.exception.ExpriedTokenException;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.InfoDto;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.PasswordDto;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.RequestJoinDto;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.exception.InvalidTokenException;
|
||||
import com.edufocus.edufocus.user.model.exception.RefreshTokenExpiredException;
|
||||
import com.edufocus.edufocus.user.model.exception.UnAuthorizedException;
|
||||
import com.edufocus.edufocus.user.model.service.UserService;
|
||||
import com.edufocus.edufocus.user.util.JWTUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -16,7 +14,6 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -35,34 +32,30 @@ public class UserController {
|
||||
private final JWTUtil jwtUtil;
|
||||
|
||||
@PostMapping("/join")
|
||||
public ResponseEntity<String> join(@RequestBody User user) throws Exception {
|
||||
userService.join(user);
|
||||
public ResponseEntity<String> join(@RequestBody RequestJoinDto requestJoinDto){
|
||||
|
||||
if(userService.isUserIdExist(requestJoinDto.getUserId()))
|
||||
return new ResponseEntity<>("아이디가 중복 됐습니다.", HttpStatus.CONFLICT);
|
||||
|
||||
userService.join(requestJoinDto);
|
||||
|
||||
return ResponseEntity.ok("User registered successfully");
|
||||
}
|
||||
// @PostMapping("/findpassword/{user_id}")
|
||||
// public ResponseEntity<String> findpassword(@PathVariable("user_id") Long user_id) throws Exception {
|
||||
// userService.userCheck(user_id);
|
||||
// return ResponseEntity.ok("임시 비밀번호가 이메일로 전송되었습니다.");
|
||||
// }
|
||||
|
||||
@PutMapping("/updateinfo")
|
||||
public ResponseEntity<String> updateUserInfo(
|
||||
@RequestBody InfoDto infoDto, HttpServletRequest request) {
|
||||
try {
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
userService.changeUserInfo(infoDto, userId);
|
||||
return ResponseEntity.ok("User info updated successfully");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.badRequest().body(e.getMessage());
|
||||
}
|
||||
public ResponseEntity<String> updateUserInfo(@RequestBody InfoDto infoDto, HttpServletRequest request) {
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
|
||||
userService.changeUserInfo(infoDto, userId);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
// 비밀번호 변경
|
||||
@PutMapping("/updatepassword")
|
||||
public ResponseEntity<String> updatePassword(@RequestBody PasswordDto passwordDto, HttpServletRequest request) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
|
||||
@ -72,79 +65,50 @@ public class UserController {
|
||||
return ResponseEntity.badRequest().body(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "로그인", description = "아이디와 비밀번호를 이용하여 로그인 처리.")
|
||||
@PostMapping("/login")
|
||||
public ResponseEntity<Map<String, Object>> login(
|
||||
@RequestBody @Parameter(description = "로그인 시 필요한 회원정보(아이디, 비밀번호).", required = true) User user, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
String token = request.getHeader("Authorization");
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
HttpStatus status = HttpStatus.ACCEPTED;
|
||||
|
||||
try {
|
||||
User loginUser = userService.login(user);
|
||||
if (loginUser != null) {
|
||||
User loginUser = userService.login(user);
|
||||
if (loginUser == null)
|
||||
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
|
||||
|
||||
String accessToken = jwtUtil.createAccessToken(String.valueOf(loginUser.getId()));
|
||||
String refreshToken = jwtUtil.createRefreshToken(String.valueOf(loginUser.getId()));
|
||||
|
||||
userService.saveRefreshToken(loginUser.getId(), refreshToken);
|
||||
|
||||
resultMap.put("name",loginUser.getName());
|
||||
resultMap.put("role",loginUser.getRole());
|
||||
resultMap.put("access-token", accessToken);
|
||||
|
||||
setCookies(response, refreshToken);
|
||||
|
||||
status = HttpStatus.CREATED;
|
||||
|
||||
|
||||
String accessToken = jwtUtil.createAccessToken(String.valueOf(loginUser.getId()));
|
||||
String refreshToken = jwtUtil.createRefreshToken(String.valueOf(loginUser.getId()));
|
||||
|
||||
userService.saveRefreshToken(loginUser.getId(), refreshToken);
|
||||
|
||||
resultMap.put("name",loginUser.getName());
|
||||
resultMap.put("role",loginUser.getRole());
|
||||
resultMap.put("access-token", accessToken);
|
||||
|
||||
Cookie refreshCookie = new Cookie("refresh-token", refreshToken);
|
||||
refreshCookie.setPath("/");
|
||||
refreshCookie.setHttpOnly(true);
|
||||
refreshCookie.setSecure(true); // HTTPS에서만 전송되도록 설정
|
||||
//refreshCookie.setSameSite(Cookie.SameSite.NONE); // Cross-Origin 요청에 대해 모두 전송
|
||||
//refreshCookie.setSameSite("None"); // Cross-Origin 요청에 대해 모두 전송
|
||||
|
||||
String cookieHeader = String.format("refresh-token=%s; Path=/; HttpOnly; Secure; SameSite=None", refreshToken);
|
||||
response.setHeader("Set-Cookie", cookieHeader);
|
||||
|
||||
// refreshCookie.setSameSite("None"); // Cross-Origin 요청에 대해 모두 전송
|
||||
response.addCookie(refreshCookie);
|
||||
|
||||
status = HttpStatus.CREATED;
|
||||
} else {
|
||||
resultMap.put("message", "아이디 또는 패스워드를 확인해 주세요.");
|
||||
status = HttpStatus.UNAUTHORIZED;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
resultMap.put("message", e.getMessage());
|
||||
status = HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
return new ResponseEntity<>(resultMap, status);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ResponseEntity<?> removeToken(HttpServletRequest request) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
HttpStatus status = HttpStatus.ACCEPTED;
|
||||
try {
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
|
||||
String token = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||
userService.deleteRefreshToken(userId);
|
||||
|
||||
userService.deleteRefreshToken(userId);
|
||||
status = HttpStatus.OK;
|
||||
} catch (Exception e) {
|
||||
log.error("로그아웃 실패 : {}", e);
|
||||
resultMap.put("message", e.getMessage());
|
||||
status = HttpStatus.UNAUTHORIZED;
|
||||
}
|
||||
return new ResponseEntity<Map<String, Object>>(resultMap, status);
|
||||
return new ResponseEntity<Map<String, Object>>(HttpStatus.ACCEPTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "Access Token 재발급", description = "만료된 access token 을 재발급 받는다.")
|
||||
@PostMapping("/refresh")
|
||||
public ResponseEntity<?> refreshToken(HttpServletRequest request,HttpServletResponse response)
|
||||
throws Exception {
|
||||
public ResponseEntity<?> refreshToken(HttpServletRequest request,HttpServletResponse response) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
String token = null;
|
||||
if (cookies != null) {
|
||||
@ -178,11 +142,7 @@ public class UserController {
|
||||
|
||||
userService.saveRefreshToken(userId,refreshToken);
|
||||
|
||||
Cookie refreshCookie = new Cookie("refresh-token", refreshToken);
|
||||
refreshCookie.setPath("/");
|
||||
refreshCookie.setHttpOnly(true);
|
||||
refreshCookie.setSecure(true);
|
||||
response.addCookie(refreshCookie);
|
||||
setCookies(response, refreshToken);
|
||||
|
||||
return new ResponseEntity<Map<String, Object>>(resultMap, HttpStatus.CREATED);
|
||||
}
|
||||
@ -215,7 +175,13 @@ public class UserController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setCookies(HttpServletResponse response, String refreshToken){
|
||||
Cookie refreshCookie = new Cookie("refresh-token", refreshToken);
|
||||
refreshCookie.setPath("/");
|
||||
refreshCookie.setHttpOnly(true);
|
||||
refreshCookie.setSecure(true);
|
||||
response.addCookie(refreshCookie);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -26,9 +26,7 @@ public class JWTInterceptor implements HandlerInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
|
||||
final String token = request.getHeader(HEADER_AUTH);
|
||||
|
||||
jwtUtil.checkToken(token);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.edufocus.edufocus.user.model.entity;
|
||||
|
||||
public enum UserRole {
|
||||
STUDENT,ADMIN
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.user.model.entity;
|
||||
package com.edufocus.edufocus.user.model.entity.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.user.model.entity;
|
||||
package com.edufocus.edufocus.user.model.entity.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
@ -1,13 +1,11 @@
|
||||
package com.edufocus.edufocus.user.model.entity;
|
||||
package com.edufocus.edufocus.user.model.entity.dto;
|
||||
|
||||
import lombok.Generated;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class PasswordDto {
|
||||
|
||||
String currentPassword;
|
||||
String newPassword;
|
||||
String newPasswordCheck;
|
@ -0,0 +1,11 @@
|
||||
package com.edufocus.edufocus.user.model.entity.dto;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class RefreshTokenDto {
|
||||
private String Token;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.edufocus.edufocus.user.model.entity.dto;
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.vo.UserRole;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class RequestJoinDto {
|
||||
private String userId;
|
||||
private String email;
|
||||
private String password;
|
||||
private UserRole role;
|
||||
private String name;
|
||||
}
|
@ -1,21 +1,14 @@
|
||||
package com.edufocus.edufocus.user.model.entity;
|
||||
package com.edufocus.edufocus.user.model.entity.vo;
|
||||
|
||||
import com.edufocus.edufocus.qna.entity.Qna;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.*;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class User {
|
@ -0,0 +1,5 @@
|
||||
package com.edufocus.edufocus.user.model.entity.vo;
|
||||
|
||||
public enum UserRole {
|
||||
STUDENT,ADMIN
|
||||
}
|
@ -19,4 +19,8 @@ public class GlobalExceptionHandler {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UserException.class)
|
||||
public ResponseEntity<String> handleUserException(UserException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.FORBIDDEN);//수정해야함
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.edufocus.edufocus.user.model.repository;
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
|
@ -1,18 +1,28 @@
|
||||
package com.edufocus.edufocus.user.model.service;
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.InfoDto;
|
||||
import com.edufocus.edufocus.user.model.entity.PasswordDto;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.InfoDto;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.PasswordDto;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.RequestJoinDto;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
|
||||
public interface UserService {
|
||||
void join(User user) throws Exception;
|
||||
User login(User user) throws Exception;
|
||||
void saveRefreshToken(Long id, String refreshToken) throws Exception;
|
||||
String getRefreshToken(Long id) throws Exception;
|
||||
void deleteRefreshToken(Long id) throws Exception;
|
||||
User userInfo(Long id) throws Exception;
|
||||
String getUserName(Long id) throws Exception;
|
||||
void changeUserInfo(InfoDto infoDto,Long id) throws Exception;
|
||||
void changePassword(PasswordDto passwordDto,Long id) throws Exception;
|
||||
void join(RequestJoinDto requestJoinDto);
|
||||
|
||||
User login(User user);
|
||||
|
||||
void saveRefreshToken(Long id, String refreshToken);
|
||||
|
||||
String getRefreshToken(Long id);
|
||||
|
||||
void deleteRefreshToken(Long id);
|
||||
|
||||
User userInfo(Long id);
|
||||
|
||||
String getUserName(Long id);
|
||||
|
||||
void changeUserInfo(InfoDto infoDto,Long id);
|
||||
|
||||
void changePassword(PasswordDto passwordDto,Long id);
|
||||
|
||||
boolean isUserIdExist(String userId);
|
||||
}
|
||||
|
@ -1,19 +1,17 @@
|
||||
package com.edufocus.edufocus.user.model.service;
|
||||
|
||||
|
||||
import com.edufocus.edufocus.user.model.entity.*;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.InfoDto;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.PasswordDto;
|
||||
import com.edufocus.edufocus.user.util.PasswordUtils;
|
||||
import com.edufocus.edufocus.user.model.entity.dto.RequestJoinDto;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.exception.UserException;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@ -25,16 +23,20 @@ public class UserServiceImpl implements UserService {
|
||||
private final UserRepository userRepository;
|
||||
|
||||
|
||||
public void join(User user)
|
||||
public void join(RequestJoinDto requestJoinDto)
|
||||
{
|
||||
System.out.println(user.getRole().getClass());
|
||||
user.setPassword(PasswordUtils.hashPassword(user.getPassword()));
|
||||
|
||||
User user = User.builder()
|
||||
.userId(requestJoinDto.getUserId())
|
||||
.email(requestJoinDto.getEmail())
|
||||
.password(PasswordUtils.hashPassword(requestJoinDto.getPassword()))
|
||||
.role(requestJoinDto.getRole())
|
||||
.name(requestJoinDto.getName())
|
||||
.build();
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
|
||||
public User login(User user) throws SQLException {
|
||||
public User login(User user){
|
||||
Optional<User> findUser = userRepository.findByUserId(user.getUserId());
|
||||
|
||||
if (findUser.isEmpty()) {
|
||||
@ -65,14 +67,13 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
|
||||
@Override
|
||||
public String getUserName(Long id) throws Exception {
|
||||
|
||||
public String getUserName(Long id){
|
||||
return userRepository.findById(id).get().getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void changeUserInfo(InfoDto infoDto, Long id) throws Exception {
|
||||
public void changeUserInfo(InfoDto infoDto, Long id){
|
||||
|
||||
User user = userRepository.findById(id).orElseThrow(IllegalArgumentException::new);
|
||||
|
||||
@ -87,18 +88,18 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
|
||||
@Override
|
||||
public void changePassword(PasswordDto passwordDto, Long id) throws Exception {
|
||||
public void changePassword(PasswordDto passwordDto, Long id){
|
||||
User user = userRepository.findById(id).orElse(null);
|
||||
|
||||
if (user == null) {
|
||||
throw new Exception("User not found");
|
||||
throw new UserException("User not found");
|
||||
}
|
||||
|
||||
if (!PasswordUtils.checkPassword(passwordDto.getCurrentPassword(), user.getPassword())) {
|
||||
throw new Exception("Current password is incorrect");
|
||||
throw new UserException("Current password is incorrect");
|
||||
} else {
|
||||
if (!passwordDto.getNewPassword().equals(passwordDto.getNewPasswordCheck())) {
|
||||
throw new Exception("New password confirmation does not match");
|
||||
throw new UserException("New password confirmation does not match");
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,6 +107,12 @@ public class UserServiceImpl implements UserService {
|
||||
user.setPassword(PasswordUtils.hashPassword(passwordDto.getNewPassword()));
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserIdExist(String userId) {
|
||||
return userRepository.findByUserId(userId).isPresent();
|
||||
}
|
||||
|
||||
public String getTempPassword() {
|
||||
char[] charSet = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
|
||||
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
|
||||
@ -119,17 +126,17 @@ public class UserServiceImpl implements UserService {
|
||||
return str;
|
||||
}
|
||||
@Override
|
||||
public void saveRefreshToken(Long id, String refreshToken) throws Exception {
|
||||
public void saveRefreshToken(Long id, String refreshToken){
|
||||
userRepository.saveRefreshToken(id, refreshToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefreshToken(Long id) throws Exception {
|
||||
public String getRefreshToken(Long id){
|
||||
return userRepository.getRefreshToken(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRefreshToken(Long id) throws Exception {
|
||||
public void deleteRefreshToken(Long id){
|
||||
userRepository.deleteRefreshToken(id);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class JWTUtil {
|
||||
Map<String, Object> value = claims.getBody();
|
||||
log.info("value : {}", value);
|
||||
return (String) value.get("id");
|
||||
}catch ( ExpiredJwtException e)
|
||||
}catch (ExpiredJwtException e)
|
||||
{
|
||||
System.out.println("expired token");
|
||||
throw new ExpriedTokenException();
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.user.model.entity;
|
||||
package com.edufocus.edufocus.user.util;
|
||||
import org.mindrot.jbcrypt.BCrypt;
|
||||
|
||||
public class PasswordUtils {
|
@ -4,13 +4,11 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.lecture.entity.LectureDetailResponse;
|
||||
import com.edufocus.edufocus.lecture.repository.LectureRepository;
|
||||
import com.edufocus.edufocus.lecture.service.LectureService;
|
||||
import com.edufocus.edufocus.registration.entity.RegistrationStatus;
|
||||
import com.edufocus.edufocus.registration.service.RegistrationService;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.UserRole;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.UserRole;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import com.edufocus.edufocus.user.model.service.UserService;
|
||||
import com.edufocus.edufocus.user.util.JWTUtil;
|
||||
@ -36,180 +34,127 @@ import livekit.LivekitWebhook.WebhookEvent;
|
||||
@RequiredArgsConstructor
|
||||
|
||||
public class Controller {
|
||||
private final JWTUtil jwtUtil;
|
||||
private final UserService userService;
|
||||
private final LectureService lectureService;
|
||||
private final VideoSertvice videoSertvice;
|
||||
private final RegistrationService registrationService;
|
||||
private final UserRepository userRepository;
|
||||
private final LectureRepository lectureRepository;
|
||||
@Value("${livekit.api.key}")
|
||||
private String LIVEKIT_API_KEY;
|
||||
private final JWTUtil jwtUtil;
|
||||
private final UserService userService;
|
||||
private final LectureService lectureService;
|
||||
private final VideoSertvice videoSertvice;
|
||||
private final RegistrationService registrationService;
|
||||
private final UserRepository userRepository;
|
||||
private final LectureRepository lectureRepository;
|
||||
|
||||
@Value("${livekit.api.secret}")
|
||||
private String LIVEKIT_API_SECRET;
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
@Value("${livekit.api.key}")
|
||||
private String LIVEKIT_API_KEY;
|
||||
|
||||
/**
|
||||
* @param params JSON object with roomName and participantName
|
||||
* @return JSON object with the JWT token
|
||||
*/
|
||||
// @PostMapping(value = "/token")
|
||||
// public ResponseEntity<Map<String, String>> createToken(@RequestBody Map<String, String> params) {
|
||||
// String roomName = params.get("roomName");
|
||||
// String participantName = params.get("participantName");
|
||||
//
|
||||
// if (roomName == null || participantName == null) {
|
||||
// return ResponseEntity.badRequest().body(Map.of("errorMessage", "roomName and participantName are required"));
|
||||
// }
|
||||
//
|
||||
// AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||
// token.setName(participantName);
|
||||
// token.setIdentity(participantName);
|
||||
// token.addGrants(new RoomJoin(true), new RoomName(roomName));
|
||||
//
|
||||
//
|
||||
//
|
||||
// return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||
// }
|
||||
|
||||
@PostMapping(value = "/makeroom/{lecture_id}")
|
||||
public ResponseEntity<String> startLecture(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception {
|
||||
@Value("${livekit.api.secret}")
|
||||
private String LIVEKIT_API_SECRET;
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
||||
String userToken = request.getHeader("Authorization");
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(userToken));
|
||||
public static String serializeIdentityData(IdentityData identityData) throws JsonProcessingException, JsonProcessingException {
|
||||
return objectMapper.writeValueAsString(identityData);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/joinroom/{lecture_id}")
|
||||
public ResponseEntity<Map<String, String>> joinRoom(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception {
|
||||
|
||||
|
||||
videoSertvice.startOnline(userId, id);
|
||||
|
||||
return new ResponseEntity<>("방만들기 성공",HttpStatus.OK);
|
||||
|
||||
}
|
||||
public static String serializeIdentityData(IdentityData identityData) throws JsonProcessingException, JsonProcessingException {
|
||||
return objectMapper.writeValueAsString(identityData);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/joinroom/{lecture_id}")
|
||||
public ResponseEntity<Map<String, String>> joinRoom(@PathVariable("lecture_id") Long id, HttpServletRequest request) throws Exception
|
||||
{
|
||||
|
||||
// 방 조인할떄 고려해야할점
|
||||
// 1. 신청됀 강의인지
|
||||
// 2. 그 강의기 On인지
|
||||
String userToken = request.getHeader("Authorization");
|
||||
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);
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(userToken));
|
||||
User findUser = userRepository.findById(userId).orElse(null);
|
||||
Lecture lecture = lectureRepository.findById(id).orElse(null);
|
||||
|
||||
|
||||
Random random = new Random();
|
||||
String roomName = lecture.getTitle();
|
||||
String participantName = userService.getUserName(userId);
|
||||
System.out.println(participantName);
|
||||
|
||||
System.out.println();
|
||||
int randomNumber = 10000 + random.nextInt(80000);
|
||||
|
||||
String randStr = String.valueOf(randomNumber);
|
||||
|
||||
String roomName = lecture.getTitle();
|
||||
String participantName = userService.getUserName(userId);
|
||||
System.out.println(participantName);
|
||||
|
||||
AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||
AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||
|
||||
|
||||
if(findUser.getRole()==UserRole.ADMIN ){//&& lecture.isOnline() ) {
|
||||
if (findUser.getRole() == UserRole.STUDENT) {
|
||||
|
||||
if (videoSertvice.isRoomAccessible(id, userId)) {
|
||||
IdentityData identityData = new IdentityData(participantName, "학생");
|
||||
String jsonIdentity = serializeIdentityData(identityData);
|
||||
|
||||
|
||||
token.setIdentity(jsonIdentity);
|
||||
token.setName(participantName);
|
||||
|
||||
IdentityData identityData = new IdentityData(participantName, "강사");
|
||||
String jsonIdentity = serializeIdentityData(identityData);
|
||||
token.addGrants(new RoomJoin(true), new RoomName(roomName));
|
||||
|
||||
|
||||
|
||||
token.setIdentity(jsonIdentity);
|
||||
token.setName(participantName);
|
||||
|
||||
token.addGrants(new RoomJoin(true), new RoomName(roomName), new RoomCreate(true));
|
||||
|
||||
videoSertvice.startOnline(userId, id);
|
||||
|
||||
System.out.println();
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||
|
||||
}
|
||||
else if(findUser.getRole()==UserRole.STUDENT )// && lecture.isOnline() )
|
||||
{
|
||||
return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body(Map.of("error", "방에 들어갈 수 없습니다."));
|
||||
}
|
||||
|
||||
|
||||
IdentityData identityData = new IdentityData(participantName, "학생");
|
||||
String jsonIdentity = serializeIdentityData(identityData);
|
||||
}
|
||||
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", null));
|
||||
|
||||
token.setIdentity(jsonIdentity);
|
||||
token.setName(participantName);
|
||||
|
||||
token.addGrants(new RoomJoin(true), new RoomName(roomName));
|
||||
}
|
||||
|
||||
|
||||
videoSertvice.startOnline(userId, id);
|
||||
@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");
|
||||
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||
}
|
||||
Long userId = Long.parseLong(jwtUtil.getUserId(userToken));
|
||||
User findUser = userRepository.findById(userId).orElse(null);
|
||||
Lecture lecture = lectureRepository.findById(id).orElse(null);
|
||||
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", null));
|
||||
String roomName = lecture.getTitle();
|
||||
String participantName = userService.getUserName(userId);
|
||||
System.out.println(participantName);
|
||||
|
||||
// String userToken = request.getHeader("Authorization");
|
||||
//
|
||||
// Long userId = Long.parseLong(jwtUtil.getUserId(userToken));
|
||||
// LectureDetailResponse lecture= lectureService.findLectureById(userId,id);
|
||||
//
|
||||
//
|
||||
// //RegistrationStatus registrationStatus = registrationService.isOnline(userId,id);
|
||||
//
|
||||
// if(registrationStatus==RegistrationStatus.ACCEPTED)
|
||||
// {
|
||||
// String roomName = lecture.getTitle();
|
||||
// String participantName = userService.getUserName(userId);
|
||||
//
|
||||
//
|
||||
// AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||
// token.setName(participantName);
|
||||
// token.setIdentity(participantName);
|
||||
// token.addGrants(new RoomJoin(true), new RoomName(roomName));
|
||||
//
|
||||
// //videoSertvice.startOnline(userId,id);
|
||||
//
|
||||
//
|
||||
//
|
||||
// return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||
// }
|
||||
// else{
|
||||
// return ResponseEntity.status(HttpStatus.FORBIDDEN).body(Map.of("errorMessage", "Not accepted"));
|
||||
//
|
||||
// }
|
||||
AccessToken token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
|
||||
|
||||
|
||||
if (findUser.getRole() == UserRole.ADMIN) {//&& lecture.isOnline() ) {
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
try {
|
||||
WebhookEvent event = webhookReceiver.receive(body, authHeader);
|
||||
System.out.println("LiveKit Webhook: " + event.toString());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error validating webhook event: " + e.getMessage());
|
||||
}
|
||||
return ResponseEntity.ok("ok");
|
||||
}
|
||||
videoSertvice.startOnline(userId, id);
|
||||
|
||||
IdentityData identityData = new IdentityData(participantName, "강사");
|
||||
String jsonIdentity = serializeIdentityData(identityData);
|
||||
|
||||
|
||||
token.setIdentity(jsonIdentity);
|
||||
token.setName(participantName);
|
||||
|
||||
token.addGrants(new RoomJoin(true), new RoomName(roomName), new RoomCreate(true));
|
||||
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", token.toJwt()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
return ResponseEntity.ok(Map.of("token", null));
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
try {
|
||||
WebhookEvent event = webhookReceiver.receive(body, authHeader);
|
||||
System.out.println("LiveKit Webhook: " + event.toString());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error validating webhook event: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
return ResponseEntity.ok("ok");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,5 +4,10 @@ import java.sql.SQLException;
|
||||
|
||||
public interface VideoSertvice {
|
||||
|
||||
void startOnline(Long userId,Long lectureId) throws SQLException;
|
||||
void startOnline(Long userId, Long lectureId) throws SQLException;
|
||||
|
||||
void stopOnline(Long userId, Long lectureId) throws SQLException;
|
||||
|
||||
boolean isRoomAccessible(Long lectureId, Long userId);
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,49 @@
|
||||
package com.edufocus.edufocus.video.service;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.lecture.entity.LectureDetailResponse;
|
||||
import com.edufocus.edufocus.lecture.service.LectureService;
|
||||
import com.edufocus.edufocus.registration.entity.RegistrationStatus;
|
||||
import com.edufocus.edufocus.registration.service.RegistrationService;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class VideoServiceImpl implements VideoSertvice{
|
||||
public class VideoServiceImpl implements VideoSertvice {
|
||||
|
||||
private final LectureService lectureService;
|
||||
private final RegistrationService registrationService;
|
||||
|
||||
private final LectureService lectureService;
|
||||
@Override
|
||||
public void startOnline(Long userId,Long lectureId) throws SQLException {
|
||||
public void startOnline(Long userId, Long lectureId) throws SQLException {
|
||||
|
||||
lectureService.changeState(lectureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopOnline(Long userId, Long lectureId) throws SQLException {
|
||||
lectureService.changeState(lectureId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRoomAccessible(Long lectureId, Long userId) {
|
||||
|
||||
|
||||
LectureDetailResponse lecture = lectureService.findLectureById(userId, userId);
|
||||
|
||||
|
||||
RegistrationStatus registrationStatus = registrationService.getStatus(userId, lectureId);
|
||||
|
||||
|
||||
if (registrationStatus == RegistrationStatus.ACCEPTED && lecture.isOnline()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.edufocus.edufocus.ws.entity.vo;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.ws.entity.dto.ChatUserDto;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
@ -3,7 +3,7 @@ package com.edufocus.edufocus.ws.service;
|
||||
|
||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||
import com.edufocus.edufocus.lecture.repository.LectureRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
import com.edufocus.edufocus.ws.entity.dto.ChatUserDto;
|
||||
import com.edufocus.edufocus.ws.entity.vo.ChatUser;
|
||||
|
@ -1,47 +1,32 @@
|
||||
spring.application.name=edufocus
|
||||
server.port=8080
|
||||
|
||||
server.ssl.enabled=false
|
||||
server.servlet.context-path=${CONTEXT_PATH}
|
||||
|
||||
# openvidu
|
||||
#server.port=${SERVER_PORT:6080}
|
||||
|
||||
|
||||
# LiveKit configuration
|
||||
livekit.api.key=${LIVEKIT_API_KEY:devkey}
|
||||
livekit.api.secret=${LIVEKIT_API_SECRET:secret}
|
||||
# JWT Salt (??? ?? ???? ???)
|
||||
|
||||
jwt.salt=${SALT}
|
||||
|
||||
# Access Token ?? ?? (??? ??)
|
||||
#jwt.access-token.expiretime=3600000
|
||||
jwt.access-token.expiretime=360000
|
||||
|
||||
jwt.access-token.expiretime=3000000
|
||||
# Refresh Token ?? ?? (??? ??)
|
||||
jwt.refresh-token.expiretime=50400000
|
||||
jwt.refresh-token.expiretime=504000000
|
||||
#jwt.refresh-token.expiretime=4000
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=${DATA_SOURCE_URL}
|
||||
spring.datasource.username=${USER_NAME}
|
||||
spring.datasource.password=${USER_PASSWORD}
|
||||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
||||
|
||||
spring.jpa.database=mysql
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
|
||||
|
||||
management.endpoints.web.exposure.include=health,info
|
||||
management.endpoint.health.show-details=always
|
||||
|
||||
|
||||
|
||||
spring.rabbitmq.host=${RABBITMQ_HOST}
|
||||
spring.rabbitmq.port=${RABBITMQ_PORT}
|
||||
spring.rabbitmq.username=${RABBITMQ_USERNAME}
|
||||
spring.rabbitmq.password=${RABBITMQ_PASSWORD}
|
||||
|
||||
|
||||
image.path=${IMAGE_PATH}
|
@ -1,8 +1,8 @@
|
||||
//package com.edufocus.edufocus.user.model.service;
|
||||
//
|
||||
//import com.edufocus.edufocus.user.model.entity.PasswordDto;
|
||||
//import com.edufocus.edufocus.user.model.entity.User;
|
||||
//import com.edufocus.edufocus.user.model.entity.UserRole;
|
||||
//import com.edufocus.edufocus.user.model.entity.dto.PasswordDto;
|
||||
//import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
//import com.edufocus.edufocus.user.model.entity.vo.UserRole;
|
||||
//import com.edufocus.edufocus.user.model.exception.UserException;
|
||||
//import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
//import org.junit.jupiter.api.BeforeEach;
|
||||
|
Loading…
Reference in New Issue
Block a user