From 1e521bbad080dd12abb71ce595866d4af5d03dc4 Mon Sep 17 00:00:00 2001 From: Jongbeom Lee <116253832+JongbeomLee623@users.noreply.github.com> Date: Sat, 2 Nov 2024 23:11:15 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"[feature]=20=EC=8B=9C=ED=97=98=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EB=B3=84=20=EC=8B=9C=ED=97=98=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C,=20=EC=8B=9C=ED=97=98?= =?UTF-8?q?=20=EC=84=B8=EC=85=98=20=EB=82=B4=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C,=20=ED=95=99?= =?UTF-8?q?=EC=83=9D=20=EB=8B=A8=EA=B1=B4=20=EC=A1=B0=ED=9A=8C=20#6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug.md | 17 +++ .github/ISSUE_TEMPLATE/feature.md | 19 +++ README.md | 2 + docs/..gitkeep | 0 src/ai/..gitkeep | 0 src/backend/..gitkeep | 0 .../common/response/BaseResponseCode.java | 7 - .../eyesee/controller/ExamController.java | 18 --- .../fortune/eyesee/dto/ExamResponseDTO.java | 1 - .../eyesee/dto/UserDetailResponseDTO.java | 57 -------- .../eyesee/dto/UserListResponseDTO.java | 38 ----- .../java/com/fortune/eyesee/entity/User.java | 25 ++-- .../CheatingStatisticsRepository.java | 14 -- .../repository/CheatingTypeRepository.java | 12 -- .../DetectedCheatingRepository.java | 14 -- .../eyesee/repository/ExamRepository.java | 3 +- .../eyesee/repository/SessionRepository.java | 12 -- .../eyesee/repository/UserRepository.java | 18 --- .../repository/VideoRecordingRepository.java | 13 -- .../fortune/eyesee/service/ExamService.java | 130 ++---------------- 20 files changed, 59 insertions(+), 341 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/feature.md create mode 100644 README.md create mode 100644 docs/..gitkeep create mode 100644 src/ai/..gitkeep create mode 100644 src/backend/..gitkeep delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserDetailResponseDTO.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserListResponseDTO.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingStatisticsRepository.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingTypeRepository.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/DetectedCheatingRepository.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/SessionRepository.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/UserRepository.java delete mode 100644 src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/VideoRecordingRepository.java diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..0570bff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,17 @@ +--- +name: Bug +about: 어떤 버그인가요? +title: "" +labels: "" +assignees: "" +--- + +### 어떤 버그인가요? + +> 어떤 버그인지 간결하게 설명해주세요 + +### 예상 결과 + +> 예상했던 정상적인 결과가 어떤 것이었는지 설명해주세요 + +### 참고할만한 자료(선택) diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 0000000..e79d750 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,19 @@ +--- +name: Feature +about: 어떤 기능을 추가하시나요? +title: "" +labels: "" +assignees: "" +--- + +### 어떤 기능인가요? + +> 추가하려는 기능에 대해 간결하게 설명해주세요 + +### 작업 상세 내용 + +- [ ] TODO +- [ ] TODO +- [ ] TODO + +### 참고할만한 자료(선택) diff --git a/README.md b/README.md new file mode 100644 index 0000000..438277a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# 2024-2-SCS4031-4tune-1 +융합캡스톤디자인 4tune - 스마트폰 카메라를 활용한 시험감독 보조 시스템 diff --git a/docs/..gitkeep b/docs/..gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/ai/..gitkeep b/src/ai/..gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/..gitkeep b/src/backend/..gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/common/response/BaseResponseCode.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/common/response/BaseResponseCode.java index 214ede5..6a53d8b 100644 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/common/response/BaseResponseCode.java +++ b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/common/response/BaseResponseCode.java @@ -43,13 +43,6 @@ public enum BaseResponseCode { NOT_FOUND_EXAM("E0001", HttpStatus.NOT_FOUND, "시험을 찾을 수 없습니다."), NOT_FOUND_EXAM_CODE("E0002", HttpStatus.NOT_FOUND, "시험 코드를 찾을 수 없습니다."), - // Exam Errors - EXAM_NOT_FOUND("E0001", HttpStatus.NOT_FOUND, "시험을 찾을 수 없습니다."), - SESSION_NOT_FOUND("E0002", HttpStatus.NOT_FOUND, "세션을 찾을 수 없습니다."), - EXAM_ALREADY_EXISTS("E0003", HttpStatus.CONFLICT, "이미 존재하는 시험입니다."), - INVALID_EXAM_STATUS("E0004", HttpStatus.BAD_REQUEST, "유효하지 않은 시험 상태입니다."), - EXAM_ACCESS_DENIED("E0005", HttpStatus.FORBIDDEN, "시험에 접근할 권한이 없습니다."), - // 기타 추가 오류 코드 ... ; diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/controller/ExamController.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/controller/ExamController.java index 08cb78f..8945916 100644 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/controller/ExamController.java +++ b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/controller/ExamController.java @@ -5,8 +5,6 @@ import com.fortune.eyesee.common.response.BaseResponseCode; import com.fortune.eyesee.dto.ExamCodeRequestDTO; import com.fortune.eyesee.dto.ExamResponseDTO; -import com.fortune.eyesee.dto.UserDetailResponseDTO; -import com.fortune.eyesee.dto.UserListResponseDTO; import com.fortune.eyesee.enums.ExamStatus; import com.fortune.eyesee.service.ExamService; import org.springframework.beans.factory.annotation.Autowired; @@ -79,20 +77,4 @@ public ResponseEntity> getExamByCode(@PathVariable return ResponseEntity.ok(new BaseResponse<>(examResponseDTO)); } - - // 특정 시험 ID에 해당하는 세션 내 모든 학생들의 리스트를 조회 - @GetMapping("/{examId}/sessions") - public ResponseEntity> getUserListByExamId(@PathVariable Integer examId) { - UserListResponseDTO response = examService.getUserListByExamId(examId); - return ResponseEntity.ok(new BaseResponse<>(response, "학생 리스트 조회 성공")); - } - - // 특정 시험 ID와 사용자 ID에 해당하는 학생의 상세 정보를 조회 - @GetMapping("/{examId}/sessions/{userId}") - public ResponseEntity> getUserDetailByExamIdAndUserId( - @PathVariable Integer examId, - @PathVariable Integer userId) { - UserDetailResponseDTO response = examService.getUserDetailByExamIdAndUserId(examId, userId); - return ResponseEntity.ok(new BaseResponse<>(response, "학생 상세 정보 조회 성공")); - } } diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/ExamResponseDTO.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/ExamResponseDTO.java index fbe91c8..515c92a 100644 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/ExamResponseDTO.java +++ b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/ExamResponseDTO.java @@ -24,5 +24,4 @@ public class ExamResponseDTO { private String examNotice; private Integer sessionId; // Session의 ID - private String examRandomCode; // 추가 examRandomCode } \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserDetailResponseDTO.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserDetailResponseDTO.java deleted file mode 100644 index 5db7ff0..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserDetailResponseDTO.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.fortune.eyesee.dto; - -import lombok.Data; -import java.util.List; - -@Data -public class UserDetailResponseDTO { - private Integer userId; - private String userName; - private Integer userNum; - private Integer seatNum; - private List cheatingStatistics; - private List cheatingVideos; - - public UserDetailResponseDTO(Integer userId, String userName, Integer userNum, Integer seatNum, - List cheatingStatistics, List cheatingVideos) { - this.userId = userId; - this.userName = userName; - this.userNum = userNum; - this.seatNum = seatNum; - this.cheatingStatistics = cheatingStatistics; - this.cheatingVideos = cheatingVideos; - } - - @Data - public static class CheatingStatistic { - private Integer cheatingStatisticsId; - private String cheatingTypeName; // String으로 변경 - private Integer cheatingCount; - private String detectedTime; - - // 부정행위 통계 생성자 - public CheatingStatistic(Integer cheatingStatisticsId, String cheatingTypeName, Integer cheatingCount, String detectedTime) { - this.cheatingStatisticsId = cheatingStatisticsId; - this.cheatingTypeName = cheatingTypeName; - this.cheatingCount = cheatingCount; - this.detectedTime = detectedTime; - } - } - - - @Data - public static class CheatingVideo { - private Integer videoId; - private String startTime; - private String endTime; - private String filepath; - - //부정행위 관련 비디오 정보 생성자 - public CheatingVideo(Integer videoId, String startTime, String endTime, String filepath) { - this.videoId = videoId; - this.startTime = startTime; - this.endTime = endTime; - this.filepath = filepath; - } - } -} diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserListResponseDTO.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserListResponseDTO.java deleted file mode 100644 index 6b863fa..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/dto/UserListResponseDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fortune.eyesee.dto; - -import lombok.Data; -import java.util.List; - -@Data -public class UserListResponseDTO { - private String examName; - private Integer examStudentNumber; - private Integer examDuration; - private List user; - - // 시험 이름, 참가자 수, 시간 등의 정보를 포함한 생성자 - public UserListResponseDTO(String examName, Integer examStudentNumber, Integer examDuration, List user) { - this.examName = examName; - this.examStudentNumber = examStudentNumber; - this.examDuration = examDuration; - this.user = user; - } - - @Data - public static class UserInfo { - private Integer userId; - private String userName; - private Integer userNum; - private Integer seatNum; - private Integer cheatingCount; - - // 사용자 고유 ID, 이름, 학번, 좌석 번호, 부정행위 횟수를 포함한 생성자 - public UserInfo(Integer userId, String userName, Integer userNum, Integer seatNum, Integer cheatingCount) { - this.userId = userId; - this.userName = userName; - this.userNum = userNum; - this.seatNum = seatNum; - this.cheatingCount = cheatingCount; - } - } -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/entity/User.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/entity/User.java index 12a217e..f802c49 100644 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/entity/User.java +++ b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/entity/User.java @@ -1,30 +1,29 @@ package com.fortune.eyesee.entity; -import jakarta.persistence.*; import lombok.Data; +import jakarta.persistence.*; + @Entity @Table(name = "User") @Data public class User { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer userId; + @Column(name = "sessionId", nullable = false) + private int sessionId; // 세션 ID (int 타입) -// @Column(name = "sessionId", nullable = false) -// private int sessionId; // 세션 ID (int 타입) -// -// @Column(nullable = false) -// private String userNum; + @Column(nullable = false) + private String userNum; - @ManyToOne - @JoinColumn(name = "sessionId", referencedColumnName = "sessionId") - private Session session; - - private Integer userNum; private String department; private String userName; - private Integer seatNum; -} + private Integer seatNum; // 좌석 번호 + + + +} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingStatisticsRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingStatisticsRepository.java deleted file mode 100644 index e2a9a96..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingStatisticsRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fortune.eyesee.repository; - - -import com.fortune.eyesee.entity.CheatingStatistics; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface CheatingStatisticsRepository extends JpaRepository { - List findByUserId(Integer userId); - int countByUserId(Integer userId); -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingTypeRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingTypeRepository.java deleted file mode 100644 index f3d5185..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/CheatingTypeRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fortune.eyesee.repository; - -import com.fortune.eyesee.entity.CheatingType; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -@Repository -public interface CheatingTypeRepository extends JpaRepository { - Optional findByCheatingTypeId(Integer cheatingTypeId); -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/DetectedCheatingRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/DetectedCheatingRepository.java deleted file mode 100644 index 89e77f8..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/DetectedCheatingRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fortune.eyesee.repository; - - -import com.fortune.eyesee.entity.DetectedCheating; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -@Repository -public interface DetectedCheatingRepository extends JpaRepository { - Optional findByUserIdAndCheatingTypeId(Integer userId, Integer cheatingTypeId); - -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/ExamRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/ExamRepository.java index 1976718..486194a 100644 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/ExamRepository.java +++ b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/ExamRepository.java @@ -2,7 +2,6 @@ import com.fortune.eyesee.entity.Exam; import com.fortune.eyesee.enums.ExamStatus; - import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -10,7 +9,6 @@ @Repository public interface ExamRepository extends JpaRepository { - // 특정 adminId에 해당하는 Exam 리스트 조회 List findByAdmin_AdminId(Integer adminId); @@ -19,4 +17,5 @@ public interface ExamRepository extends JpaRepository { // 랜덤 코드와 adminId로 Exam 조회 Exam findByExamRandomCode(String examRandomCode); + } \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/SessionRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/SessionRepository.java deleted file mode 100644 index f89ee55..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/SessionRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fortune.eyesee.repository; - -import com.fortune.eyesee.entity.Session; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface SessionRepository extends JpaRepository { - List findByExam_ExamId(Integer examId); -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/UserRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/UserRepository.java deleted file mode 100644 index e8ca963..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/UserRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fortune.eyesee.repository; - -import com.fortune.eyesee.entity.Session; -import com.fortune.eyesee.entity.User; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Optional; - -@Repository -public interface UserRepository extends JpaRepository { - // Session 객체로 사용자 리스트를 검색하는 메소드 - List findBySession(Session session); - - // Session과 UserId로 특정 사용자 검색하는 메소드 - Optional findBySessionAndUserId(Session session, Integer userId); -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/VideoRecordingRepository.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/VideoRecordingRepository.java deleted file mode 100644 index f4ef8ae..0000000 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/repository/VideoRecordingRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fortune.eyesee.repository; - - -import com.fortune.eyesee.entity.VideoRecording; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface VideoRecordingRepository extends JpaRepository { - List findByUserId(Integer userId); -} \ No newline at end of file diff --git a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/service/ExamService.java b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/service/ExamService.java index 7405f5f..8ddf717 100644 --- a/src/backend/Eyesee/src/main/java/com/fortune/eyesee/service/ExamService.java +++ b/src/backend/Eyesee/src/main/java/com/fortune/eyesee/service/ExamService.java @@ -3,53 +3,26 @@ import com.fortune.eyesee.common.exception.BaseException; import com.fortune.eyesee.common.response.BaseResponseCode; import com.fortune.eyesee.dto.ExamResponseDTO; -import com.fortune.eyesee.dto.UserDetailResponseDTO; -import com.fortune.eyesee.dto.UserListResponseDTO; -import com.fortune.eyesee.entity.*; +import com.fortune.eyesee.entity.Exam; import com.fortune.eyesee.enums.ExamStatus; -import com.fortune.eyesee.repository.*; +import com.fortune.eyesee.repository.ExamRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; @Service public class ExamService { - private final ExamRepository examRepository; - private final UserRepository userRepository; - private final SessionRepository sessionRepository; - private final CheatingStatisticsRepository cheatingStatisticsRepository; - private final VideoRecordingRepository videoRecordingRepository; - private final DetectedCheatingRepository detectedCheatingRepository; - private final CheatingTypeRepository cheatingTypeRepository; - @Autowired - public ExamService(ExamRepository examRepository, - UserRepository userRepository, - SessionRepository sessionRepository, - CheatingStatisticsRepository cheatingStatisticsRepository, - VideoRecordingRepository videoRecordingRepository, - DetectedCheatingRepository detectedCheatingRepository, - CheatingTypeRepository cheatingTypeRepository) { - this.examRepository = examRepository; - this.userRepository = userRepository; - this.sessionRepository = sessionRepository; - this.cheatingStatisticsRepository = cheatingStatisticsRepository; - this.videoRecordingRepository = videoRecordingRepository; - this.detectedCheatingRepository = detectedCheatingRepository; - this.cheatingTypeRepository = cheatingTypeRepository; - } + private ExamRepository examRepository; - // 특정 시험 ID로 존재 여부 확인 public boolean existsById(Integer examId) { return examRepository.existsById(examId); } - // Admin ID와 ExamStatus로 시험 목록 조회 + // 관리자 ID와 특정 ExamStatus로 Exam 리스트 조회 public List getExamsByStatus(Integer adminId, ExamStatus examStatus) { return examRepository.findByAdmin_AdminIdAndExamStatus(adminId, examStatus).stream() .map(exam -> new ExamResponseDTO( @@ -63,14 +36,13 @@ public List getExamsByStatus(Integer adminId, ExamStatus examSt exam.getExamDuration(), exam.getExamStatus(), exam.getExamNotice(), - exam.getSession() != null ? exam.getSession().getSessionId() : null, - exam.getExamRandomCode() + exam.getSession() != null ? exam.getSession().getSessionId() : null )) .collect(Collectors.toList()); } - // ExamCode로 시험 조회 public ExamResponseDTO getExamByCode(String examCode) { + Exam exam = examRepository.findByExamRandomCode(examCode); if (exam == null) { throw new BaseException(BaseResponseCode.NOT_FOUND_EXAM_CODE); @@ -86,93 +58,7 @@ public ExamResponseDTO getExamByCode(String examCode) { exam.getExamDuration(), exam.getExamStatus(), exam.getExamNotice(), - exam.getSession() != null ? exam.getSession().getSessionId() : null, - examCode - ); - } - - // 특정 Exam ID로 사용자 리스트 조회 - public UserListResponseDTO getUserListByExamId(Integer examId) { - Exam exam = examRepository.findById(examId) - .orElseThrow(() -> new IllegalArgumentException("시험을 찾을 수 없습니다")); - - List users = new ArrayList<>(); - List sessions = sessionRepository.findByExam_ExamId(examId); // 수정된 부분 - for (Session session : sessions) { - List sessionUsers = userRepository.findBySession(session); - List sessionUserInfo = sessionUsers.stream() - .map(user -> { - int cheatingCount = cheatingStatisticsRepository.countByUserId(user.getUserId()); - return new UserListResponseDTO.UserInfo( - user.getUserId(), - user.getUserName(), - user.getUserNum(), - user.getSeatNum(), - cheatingCount - ); - }) - .collect(Collectors.toList()); - users.addAll(sessionUserInfo); - } - - return new UserListResponseDTO( - exam.getExamName(), - exam.getExamStudentNumber(), - exam.getExamDuration(), - users - ); - } - - - // 특정 Exam ID와 User ID로 User 상세 정보 조회 - public UserDetailResponseDTO getUserDetailByExamIdAndUserId(Integer examId, Integer userId) { - List sessions = sessionRepository.findByExam_ExamId(examId); // 수정된 부분 - if (sessions.isEmpty()) { - throw new IllegalArgumentException("시험을 찾을 수 없거나 세션이 없습니다"); - } - - Optional userOpt = sessions.stream() - .map(session -> userRepository.findBySessionAndUserId(session, userId)) - .filter(Optional::isPresent) - .map(Optional::get) - .findFirst(); - - User user = userOpt.orElseThrow(() -> new IllegalArgumentException("사용자를 찾을 수 없습니다")); - - - List cheatingStatistics = cheatingStatisticsRepository.findByUserId(userId).stream() - .map(stat -> { - String cheatingTypeName = cheatingTypeRepository.findById(stat.getCheatingTypeId()) - .map(CheatingType::getCheatingTypeName) - .orElse("알 수 없음"); - - return new UserDetailResponseDTO.CheatingStatistic( - stat.getCheatingStatisticsId(), - cheatingTypeName, - stat.getCheatingCount(), - detectedCheatingRepository.findByUserIdAndCheatingTypeId(userId, stat.getCheatingTypeId()) - .map(detected -> detected.getDetectedTime() != null ? detected.getDetectedTime().toString() : null) - .orElse(null) - ); - }) - .collect(Collectors.toList()); - - List cheatingVideos = videoRecordingRepository.findByUserId(userId).stream() - .map(video -> new UserDetailResponseDTO.CheatingVideo( - video.getVideoId(), - video.getStartTime().toString(), - video.getEndTime().toString(), - video.getFilePath() - )) - .collect(Collectors.toList()); - - return new UserDetailResponseDTO( - user.getUserId(), - user.getUserName(), - user.getUserNum(), - user.getSeatNum(), - cheatingStatistics, - cheatingVideos + exam.getSession() != null ? exam.getSession().getSessionId() : null // 세션 ID가 있을 경우 ); } -} +} \ No newline at end of file