From 337b5fd0ef3e41d1a186d8e2d66473b706e82795 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 19:54:40 +0900 Subject: [PATCH 01/14] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20:=20commentService=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=B4=20=EB=A6=AC=ED=8C=A9=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blacklist/service/BlacklistService.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/blacklist/service/BlacklistService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/blacklist/service/BlacklistService.java index 590dae5b..c2ba915a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/blacklist/service/BlacklistService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/blacklist/service/BlacklistService.java @@ -40,10 +40,7 @@ public class BlacklistService { // 1. flag는 볼필요 없음. -> 학생, 강사만 구분해야함. public List findAllBlacklistByMemberType(MemberType memberType) { - - List blacklistDTOList = blacklistRepository.findAllBlacklistByMemberType(memberType); - - return blacklistDTOList; + return blacklistRepository.findAllBlacklistByMemberType(memberType); } // 1. 멤버 타입에 따라 신고내역 횟수 뒤져서 찾기 reportService.findCount @@ -72,8 +69,8 @@ public List findBlacklistReportComment(Long memberCod // 2. ReportDTO의 comment_code 내역 가져오기 -> comment table List commentDTOList = reportDTOlist.stream() - .map(reportDTO -> commentService.findComentByCommentCode(reportDTO.getCommentCode())) - .collect(Collectors.toList()); + .map(reportDTO -> commentService.findCommentByCommentCode(reportDTO.getCommentCode())) + .toList(); // 3. List 생성 및 데이터 추가 List blacklistReportCommentDTOList = new ArrayList<>(); @@ -111,10 +108,8 @@ public void addMemberToBlacklist(BlacklistDTO dto) { public List filterBlacklistMember(BlacklistFilterRequestDTO dto){ List blacklistList = blacklistRepository.searchBy(dto); - List blacklistDTOList = blacklistList.stream() + return blacklistList.stream() .map(blacklistMapper::fromBlacklistToBlacklistDTO) .collect(Collectors.toList()); - - return blacklistDTOList; } } From 9a5e00bac9a25a7f6d87d5c6dfeb5a69d107cc4b Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 19:55:47 +0900 Subject: [PATCH 02/14] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20:=20CommentController=20=EC=9E=90?= =?UTF-8?q?=EB=A3=8C=ED=98=95=20=EC=88=98=EC=A0=95,=20PathVariable=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../learnsmate/comment/controller/CommentController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java index e7c6f732..ccea118c 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/controller/CommentController.java @@ -32,9 +32,9 @@ public ResponseEntity> findAllComments() { } @Operation(summary = "댓글 단건 조회") - @GetMapping("/{commentcode}") - public ResponseEntity findCommentByCommentCode(@PathVariable("commentcode") Long commentCode) { - CommentDTO commentDTO = commentService.findComentByCommentCode(commentCode); + @GetMapping("/{commentCode}") + public ResponseEntity findCommentByCommentCode(@PathVariable("commentCode") Long commentCode) { + CommentDTO commentDTO = commentService.findCommentByCommentCode(commentCode); return ResponseEntity.status(HttpStatus.OK) .body(commentMapper.fromCommentDTOToResponseFindCommentVO(commentDTO)); @@ -43,7 +43,7 @@ public ResponseEntity findCommentByCommentCode(@PathVaria @Operation(summary = "강의별 댓글 조회") @GetMapping("/lecture/{lectureCode}") - public ResponseEntity> findCommentByLectureCode(@PathVariable("lectureCode") Long lectureCode ) { + public ResponseEntity> findCommentByLectureCode(@PathVariable("lectureCode") String lectureCode ) { List commentDTOList = commentService.findCommentByLectureCode(lectureCode); return ResponseEntity.status(HttpStatus.OK).body(commentDTOList.stream() From bf5d3c2c539e47593e310773cb6d7797c4119834 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 19:56:20 +0900 Subject: [PATCH 03/14] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20:=20CommentService=20=EC=9E=90=EB=A3=8C?= =?UTF-8?q?=ED=98=95=20=EC=88=98=EC=A0=95,=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/service/CommentService.java | 5 ++--- .../comment/service/CommentServiceImpl.java | 15 +++++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java index b47283a3..2a6d405f 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentService.java @@ -7,8 +7,7 @@ public interface CommentService { List findAllComments(); - CommentDTO findComentByCommentCode(Long commentCode); + CommentDTO findCommentByCommentCode(Long commentCode); - // 강의별 댓글 1개 조회 - List findCommentByLectureCode(Long lectureCode); + List findCommentByLectureCode(String lectureCode); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java index adc28a6e..74969932 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/service/CommentServiceImpl.java @@ -1,6 +1,5 @@ package intbyte4.learnsmate.comment.service; - import intbyte4.learnsmate.comment.domain.dto.CommentDTO; import intbyte4.learnsmate.comment.domain.entity.Comment; import intbyte4.learnsmate.comment.mapper.CommentMapper; @@ -34,9 +33,7 @@ public class CommentServiceImpl implements CommentService { private final MemberMapper memberMapper; @Override - // 모든 댓글 조회 public List findAllComments() { - // 1. repo에 있는 모든 데이터 조회하면 됨. List commentList = commentRepository.findAll(); return commentList.stream() @@ -45,8 +42,7 @@ public List findAllComments() { } @Override - // 댓글 1개 조회 - public CommentDTO findComentByCommentCode(Long commentCode) { + public CommentDTO findCommentByCommentCode(Long commentCode) { Comment comment = commentRepository.findById(commentCode) .orElseThrow(() -> new CommonException(StatusEnum.COMMENT_NOT_FOUND)); @@ -54,13 +50,12 @@ public CommentDTO findComentByCommentCode(Long commentCode) { } @Override - // 강의별 댓글 1개 조회 - public List findCommentByLectureCode(Long lectureCode) { + public List findCommentByLectureCode(String lectureCode) { LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); - MemberDTO studentDTO = memberService.findMemberByMemberCode(lectureDTO.getLectureCode(), MemberType.STUDENT); - Member member = memberMapper.fromMemberDTOtoMember(studentDTO); - Lecture lecture = lectureMapper.toEntity(lectureDTO,member); + MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); + Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); + Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); List commentList = commentRepository.findByLecture(lecture); From 90bcf38ad0185327340fd86bec126976a15ad397 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 19:56:36 +0900 Subject: [PATCH 04/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20=EA=B3=84=EC=95=BD=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ContractProcessController.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/controller/ContractProcessController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/controller/ContractProcessController.java index 11fabfe4..fff8834d 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/controller/ContractProcessController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/controller/ContractProcessController.java @@ -13,8 +13,11 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + @RestController -@RequestMapping("/contractprocess") +@RequestMapping("/contract-process") @Slf4j @RequiredArgsConstructor public class ContractProcessController { @@ -22,6 +25,18 @@ public class ContractProcessController { private final ContractProcessService contractProcessService; private final ContractProcessMapper contractProcessMapper; + @Operation(summary = "계약과정 전체 조회") + @GetMapping("list") + public ResponseEntity> listContractProcess() { + List contractProcessDTOList = contractProcessService.findAll(); + List response = new ArrayList<>(); + for (ContractProcessDTO contractProcessDTO : contractProcessDTOList) { + ResponseFindContractProcessVO responseVO = contractProcessMapper.fromDtoToResponseVO(contractProcessDTO); + response.add(responseVO); + } + return ResponseEntity.status(HttpStatus.OK).body(response); + } + @Operation(summary = "계약과정코드로 계약과정 단건 조회") @GetMapping("/{contractProcessCode}") public ResponseEntity getContractProcess(@PathVariable("contractProcessCode") Long contractProcessCode) { @@ -31,19 +46,16 @@ public ResponseEntity getContractProcess(@PathVar @Operation(summary = "강의별 계약과정 조회") @GetMapping("/lecture/{lectureCode}") - public ResponseEntity getApprovalProcessByLectureCode( - @PathVariable("lectureCode") Long lectureCode) { + public ResponseEntity getApprovalProcessByLectureCode(@PathVariable("lectureCode") String lectureCode) { ContractProcessDTO contractProcessDTO = contractProcessService.getApprovalProcessByLectureCode(lectureCode); return ResponseEntity.status(HttpStatus.OK).body(contractProcessMapper.fromDtoToResponseVO(contractProcessDTO)); } - @Operation(summary = "강의별 계약과정 등록") - @PutMapping("/lecture/{lectureCode}") + @PostMapping("/lecture-approve/{lectureCode}") public ResponseEntity createContractProcessByLecture( - @PathVariable("lectureCode") Long lectureCode, @RequestBody RequestRegisterContractProcessVO requestVO) { + @PathVariable("lectureCode") String lectureCode, @RequestBody RequestRegisterContractProcessVO requestVO) { ContractProcessDTO contractProcessDTO = contractProcessService.createContractProcess(lectureCode,contractProcessMapper.fromRegisterRequestVOtoDto(requestVO)); return ResponseEntity.status(HttpStatus.CREATED).body(contractProcessMapper.fromDtoToRegisterResponseVO(contractProcessDTO)); } - } From 73956ef90fe40de0969fbdefc51582e4dbb96756 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 19:56:55 +0900 Subject: [PATCH 05/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20=EA=B3=84=EC=95=BD=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=20=EC=84=9C=EB=B9=84=EC=8A=A4=20-=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ContractProcessService.java | 7 +++-- .../service/ContractProcessServiceImpl.java | 30 +++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java index fc53bc3b..63bff23e 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessService.java @@ -2,14 +2,17 @@ import intbyte4.learnsmate.contractprocess.domain.dto.ContractProcessDTO; +import java.util.List; + public interface ContractProcessService { // 단건 조회 ContractProcessDTO getContractProcess(Long contractProcessCode); // 강의별 승인과정 절차 조회 - ContractProcessDTO getApprovalProcessByLectureCode(Long lectureCode); + ContractProcessDTO getApprovalProcessByLectureCode(String lectureCode); // 계약과정 등록 - ContractProcessDTO createContractProcess(Long lectureCode, ContractProcessDTO contractProcessDTO); + ContractProcessDTO createContractProcess(String lectureCode, ContractProcessDTO contractProcessDTO); + List findAll(); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java index b9276fea..47dc1b57 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/service/ContractProcessServiceImpl.java @@ -24,6 +24,8 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; @Service @@ -38,8 +40,6 @@ public class ContractProcessServiceImpl implements ContractProcessService { private final LectureService lectureService; private final LectureMapper lectureMapper; - - // 단건 조회 @Override public ContractProcessDTO getContractProcess(Long contractProcessCode) { ContractProcess contractProcess = contractProcessRepository.findById(contractProcessCode) @@ -47,13 +47,11 @@ public ContractProcessDTO getContractProcess(Long contractProcessCode) { return contractProcessMapper.toDTO(contractProcess); } - - // 강의별 승인과정 절차 조회 @Override - public ContractProcessDTO getApprovalProcessByLectureCode(Long lectureCode) { + public ContractProcessDTO getApprovalProcessByLectureCode(String lectureCode) { LectureDTO lecturedto = lectureService.getLectureById(lectureCode); - MemberDTO tutorDTO = memberService.findMemberByMemberCode(lecturedto.getLectureCode(), MemberType.TUTOR); + MemberDTO tutorDTO = memberService.findMemberByMemberCode(lecturedto.getTutorCode(), MemberType.TUTOR); Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); Lecture lecture = lectureMapper.toEntity(lecturedto, tutor); @@ -67,12 +65,9 @@ public ContractProcessDTO getApprovalProcessByLectureCode(Long lectureCode) { return contractProcessMapper.toDTO(contractProcess); } - - - // 계약과정 등록 @Transactional @Override - public ContractProcessDTO createContractProcess(Long lectureCode, ContractProcessDTO contractProcessDTO) { + public ContractProcessDTO createContractProcess(String lectureCode, ContractProcessDTO contractProcessDTO) { LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); @@ -82,12 +77,10 @@ public ContractProcessDTO createContractProcess(Long lectureCode, ContractProces AdminDTO adminDTO = adminService.findByAdminCode(contractProcessDTO.getAdminCode()); Admin admin = adminMapper.toEntity(adminDTO); - // 강의별 계약과정 ApprovalProcess이 같은 강의 코드와 같은 ApprovalProcess의 값이 존재하는지 확인 ContractProcess existingContractProcess = contractProcessRepository .findByLectureAndApprovalProcess(lecture, contractProcessDTO.getApprovalProcess()) .orElse(null); - // 이미 존재하는 계약과정이 있으면 예외 처리 if (existingContractProcess != null) { throw new CommonException(StatusEnum.EXISTING_CONTRACT_PROCESS); } @@ -102,10 +95,9 @@ public ContractProcessDTO createContractProcess(Long lectureCode, ContractProces contractProcessRepository.save(contractProcess); - long contractProcessCount = contractProcessRepository.countByLecture(lecture); + int contractProcessCount = contractProcessRepository.countByLecture(lecture); LectureDTO lecturedto = lectureMapper.toDTO(lecture); - // 계약과정이 7개일 경우 강의 승인 상태 변경 if (contractProcessCount == 7) { lectureService.updateLectureConfirmStatus(lecturedto.getLectureCode()); } @@ -113,5 +105,13 @@ public ContractProcessDTO createContractProcess(Long lectureCode, ContractProces return contractProcessMapper.toDTO(contractProcess); } - + @Override + public List findAll() { + List contractProcessList = contractProcessRepository.findAll(); + List contractProcessDTOList = new ArrayList<>(); + for (ContractProcess contractProcess : contractProcessList) { + contractProcessDTOList.add(contractProcessMapper.toDTO(contractProcess)); + } + return contractProcessDTOList; + } } From a90233f61ba7bc51d29454fc3bafdef133d85035 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 19:57:14 +0900 Subject: [PATCH 06/14] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20:=20=EA=B3=84=EC=95=BD=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=95=20=EB=A6=AC=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=20-?= =?UTF-8?q?=20=EC=9E=90=EB=A3=8C=ED=98=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contractprocess/repository/ContractProcessRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java index c50a76f1..2125e551 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/repository/ContractProcessRepository.java @@ -16,5 +16,5 @@ public interface ContractProcessRepository extends JpaRepository findByLectureAndApprovalProcess(Lecture lecture, Integer approvalProcess); - long countByLecture(Lecture lecture); + int countByLecture(Lecture lecture); } \ No newline at end of file From bdc809c0684dfda48273d64b8f64e94bf21617e0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:08:11 +0900 Subject: [PATCH 07/14] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20:=20lectureCode=20=EC=9E=90=EB=A3=8C?= =?UTF-8?q?=ED=98=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/domain/dto/CommentDTO.java | 2 +- .../vo/request/ResponseFindCommentVO.java | 2 +- .../domain/dto/ContractProcessDTO.java | 2 +- .../ResponseRegisterContractProcessVO.java | 2 +- .../RequestRegisterContractProcessVO.java | 2 +- .../ResponseFindContractProcessVO.java | 2 +- .../coupon/controller/CouponController.java | 2 +- .../coupon/service/CouponFacade.java | 2 +- .../domain/dto/CouponByLectureDTO.java | 2 +- .../CouponByLectureFindResponseVO.java | 2 +- .../lecture/domain/dto/LectureDTO.java | 2 +- .../lecture/domain/dto/LectureDetailDTO.java | 38 +++++++++---------- .../lecture/domain/dto/LectureFilterDTO.java | 9 +++-- .../lecture/domain/entity/Lecture.java | 8 ++-- .../vo/request/RequestEditLectureInfoVO.java | 3 -- .../vo/request/RequestLectureFilterVO.java | 2 +- .../vo/response/ResponseFindLectureVO.java | 2 +- .../vo/response/ResponseRemoveLectureVO.java | 2 +- .../lecture/repository/LectureRepository.java | 3 +- .../LectureByStudentRepository.java | 6 +-- .../service/LectureByStudentService.java | 4 +- .../service/LectureByStudentServiceImpl.java | 4 +- .../dto/LectureCategoryByLectureDTO.java | 2 +- .../domain/dto/OneLectureCategoryListDTO.java | 16 -------- ...esponseFindLectureCategoryByLectureVO.java | 2 +- .../LectureCategoryByLectureRepository.java | 9 ++++- .../domain/dto/LectureVideoProgressDTO.java | 2 +- .../LectureVideoByStudentRepository.java | 4 +- .../LectureVideoByStudentServiceImpl.java | 6 +-- .../payment/domain/dto/PaymentDetailDTO.java | 2 +- .../domain/vo/PaymentFilterRequestVO.java | 4 +- .../domain/vo/ResponseFindPaymentVO.java | 2 +- .../CustomPaymentRepositoryImpl.java | 2 +- .../controller/VideoByLectureController.java | 4 +- .../domain/dto/CountVideoByLectureDTO.java | 2 +- .../domain/dto/VideoByLectureDTO.java | 2 +- .../ResponseFindVideoByLectureVO.java | 2 +- .../service/VideoByLectureService.java | 6 +-- .../service/VideoByLectureServiceImpl.java | 16 +++----- 39 files changed, 82 insertions(+), 104 deletions(-) delete mode 100644 LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/OneLectureCategoryListDTO.java diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/dto/CommentDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/dto/CommentDTO.java index 5271237d..32143fbb 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/dto/CommentDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/dto/CommentDTO.java @@ -16,5 +16,5 @@ public class CommentDTO { private LocalDateTime createdAt; private LocalDateTime updatedAt; private Long memberCode; - private Long lectureCode; + private String lectureCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/vo/request/ResponseFindCommentVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/vo/request/ResponseFindCommentVO.java index fd815089..514c9cfe 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/vo/request/ResponseFindCommentVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/comment/domain/vo/request/ResponseFindCommentVO.java @@ -19,5 +19,5 @@ public class ResponseFindCommentVO { private LocalDateTime createdAt; private LocalDateTime updatedAt; private Long memberCode; - private Long lectureCode; + private String lectureCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/dto/ContractProcessDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/dto/ContractProcessDTO.java index 782b8ee2..4eb04b9c 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/dto/ContractProcessDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/dto/ContractProcessDTO.java @@ -17,6 +17,6 @@ public class ContractProcessDTO { private Integer approvalProcess; private LocalDateTime createdAt; private String note; - private Long lectureCode; + private String lectureCode; private Long adminCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/request/ResponseRegisterContractProcessVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/request/ResponseRegisterContractProcessVO.java index 406e7c4d..0f71fb9a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/request/ResponseRegisterContractProcessVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/request/ResponseRegisterContractProcessVO.java @@ -17,6 +17,6 @@ public class ResponseRegisterContractProcessVO { private Integer approvalProcess; private LocalDateTime createdAt; private String note; - private Long lectureCode; + private String lectureCode; private Long adminCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/RequestRegisterContractProcessVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/RequestRegisterContractProcessVO.java index 38735752..84602337 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/RequestRegisterContractProcessVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/RequestRegisterContractProcessVO.java @@ -18,6 +18,6 @@ public class RequestRegisterContractProcessVO { private Integer approvalProcess; private LocalDateTime createdAt; private String note; - private Long lectureCode; + private String lectureCode; private Long adminCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/ResponseFindContractProcessVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/ResponseFindContractProcessVO.java index 0396f0f4..ef26c08d 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/ResponseFindContractProcessVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/contractprocess/domain/vo/response/ResponseFindContractProcessVO.java @@ -18,6 +18,6 @@ public class ResponseFindContractProcessVO { private Integer approvalProcess; private LocalDateTime createdAt; private String note; - private Long lectureCode; + private String lectureCode; private Long adminCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java index 5fe326c1..012c3eab 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/controller/CouponController.java @@ -64,7 +64,7 @@ public ResponseEntity createCoupon(@RequestBody AdminC @Operation(summary = "강사 - 쿠폰 등록") @PostMapping("/tutor/register") - public ResponseEntity createCoupon(@RequestBody TutorCouponRegisterRequestVO request, Member tutor, CouponCategory couponCategory, Long lectureCode) { + public ResponseEntity createCoupon(@RequestBody TutorCouponRegisterRequestVO request, Member tutor, CouponCategory couponCategory, String lectureCode) { CouponDTO couponDTO = couponFacade.tutorRegisterCoupon(request, tutor, couponCategory, lectureCode); return ResponseEntity.status(HttpStatus.CREATED).body(couponMapper.fromDTOToRegisterResponseVO(couponDTO)); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java index 6718183c..057bf777 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon/service/CouponFacade.java @@ -26,7 +26,7 @@ public class CouponFacade { private final LectureMapper lectureMapper; @Transactional - public CouponDTO tutorRegisterCoupon(TutorCouponRegisterRequestVO request, Member tutor, CouponCategory couponCategory, Long lectureCode) { + public CouponDTO tutorRegisterCoupon(TutorCouponRegisterRequestVO request, Member tutor, CouponCategory couponCategory, String lectureCode) { CouponEntity newCouponEntity = couponMapper.newCouponEntity(request, tutor, couponCategory); LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/dto/CouponByLectureDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/dto/CouponByLectureDTO.java index b6757387..e2c4317f 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/dto/CouponByLectureDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/dto/CouponByLectureDTO.java @@ -11,5 +11,5 @@ public class CouponByLectureDTO { private Long couponByLectureCode; private Long couponCode; - private Long lectureCode; + private String lectureCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/vo/response/CouponByLectureFindResponseVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/vo/response/CouponByLectureFindResponseVO.java index 3cb89429..562013aa 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/vo/response/CouponByLectureFindResponseVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/coupon_by_lecture/domain/vo/response/CouponByLectureFindResponseVO.java @@ -18,6 +18,6 @@ public class CouponByLectureFindResponseVO { private Long couponCode; @JsonProperty("lecture_code") - private Long lectureCode; + private String lectureCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDTO.java index 8f71773b..72f31d9a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDTO.java @@ -12,7 +12,7 @@ @NoArgsConstructor @AllArgsConstructor public class LectureDTO { - private Long lectureCode; + private String lectureCode; private String lectureTitle; private Boolean lectureConfirmStatus; private LocalDateTime createdAt; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDetailDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDetailDTO.java index b5830748..77677097 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDetailDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureDetailDTO.java @@ -1,31 +1,31 @@ package intbyte4.learnsmate.lecture.domain.dto; -import intbyte4.learnsmate.lecture.domain.entity.LectureLevelEnum; import intbyte4.learnsmate.video_by_lecture.domain.dto.VideoByLectureDTO; import lombok.*; import java.time.LocalDateTime; import java.util.List; +@AllArgsConstructor +@NoArgsConstructor @Getter -@Builder +@Setter @ToString -@NoArgsConstructor -@AllArgsConstructor +@Builder public class LectureDetailDTO { - private Long lectureCode; // 강의코드 - private String lectureTitle; // 강의명 - private Boolean lectureConfirmStatus; // 강의 계약 상태 - private LocalDateTime createdAt; // 강의 생성일 - private String lectureImage; // 강의 이미지 - private Integer lecturePrice; // 금액 - private Long tutorCode; // 강사 코드 - private String tutorName; // 강사 명 - private Boolean lectureStatus; // 강의 상태 - private String lectureCategory; // 강의 카테고리 - private Integer lectureClickCount; // 강의 조회수 - private String lectureLevel; // 강의 난이도 - private int totalStudents; // 누적 수강생 - private int totalRevenue; // 누적 매출액 - private List lectureVideos; // 강의 동영상 정보 + private String lectureCode; + private String lectureTitle; + private Boolean lectureConfirmStatus; + private LocalDateTime createdAt; + private String lectureImage; + private Integer lecturePrice; + private Long tutorCode; + private String tutorName; + private Boolean lectureStatus; + private String lectureCategory; + private Integer lectureClickCount; + private String lectureLevel; + private int totalStudents; + private int totalRevenue; + private List lectureVideos; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureFilterDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureFilterDTO.java index 31aef938..4c025ca1 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureFilterDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/LectureFilterDTO.java @@ -5,13 +5,14 @@ import java.time.LocalDateTime; +@AllArgsConstructor +@NoArgsConstructor @Getter -@Builder +@Setter @ToString -@NoArgsConstructor -@AllArgsConstructor +@Builder public class LectureFilterDTO { - private Long lectureCode; // 강의 코드 + private String lectureCode; // 강의 코드 private String lectureTitle; // 강의명 private Long tutorCode; // 강사 코드 private String tutorName; // 강사명 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java index 913a2fed..6b36bc22 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/entity/Lecture.java @@ -19,7 +19,7 @@ public class Lecture { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "lecture_code", nullable = false) - private Long lectureCode; + private String lectureCode; @Column(name = "lecture_title", nullable = false) private String lectureTitle; @@ -54,7 +54,6 @@ public class Lecture { @Column(name = "lecture_level", nullable = false) private LectureLevelEnum lectureLevel; - public void toUpdate(LectureDTO lectureDTO) { this.lectureTitle = lectureDTO.getLectureTitle(); this.lectureConfirmStatus = lectureDTO.getLectureConfirmStatus(); @@ -76,8 +75,7 @@ public void toAcceptConfirmStatus(){ this.updatedAt = LocalDateTime.now(); } - public void incrementClickCount() { - this.lectureClickCount++; + public void setLectureCode(String lectureCode) { + this.lectureCode = lectureCode; } - } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestEditLectureInfoVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestEditLectureInfoVO.java index 36e30100..24c251c2 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestEditLectureInfoVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestEditLectureInfoVO.java @@ -15,12 +15,9 @@ @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class RequestEditLectureInfoVO { private String lectureTitle; - private Boolean lectureConfirmStatus; private LocalDateTime updatedAt; private String lectureImage; private Integer lecturePrice; - private Boolean lectureStatus; - private Integer lectureClickCount; private LectureLevelEnum lectureLevel; private String newVideoTitle; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestLectureFilterVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestLectureFilterVO.java index b93bab58..29e4037b 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestLectureFilterVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/request/RequestLectureFilterVO.java @@ -15,7 +15,7 @@ @Builder @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class RequestLectureFilterVO { - private Long lectureCode; // 강의 코드 + private String lectureCode; // 강의 코드 private String lectureTitle; // 강의명 private Long tutorCode; // 강사 코드 private String tutorName; // 강사명 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseFindLectureVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseFindLectureVO.java index e727b21d..34dae8d4 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseFindLectureVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseFindLectureVO.java @@ -15,7 +15,7 @@ @Builder @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class ResponseFindLectureVO { - private Long lectureCode; // 강의코드 + private String lectureCode; // 강의코드 private String lectureTitle; // 강의명 private Boolean lectureConfirmStatus; // 강의 계약 상태 private LocalDateTime createdAt; // 강의 생성일 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRemoveLectureVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRemoveLectureVO.java index 7ee7715a..1978d073 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRemoveLectureVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/vo/response/ResponseRemoveLectureVO.java @@ -16,7 +16,7 @@ @Builder @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class ResponseRemoveLectureVO { - private Long lectureCode; + private String lectureCode; private String lectureTitle; private Boolean lectureConfirmStatus; private LocalDateTime createdAt; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/repository/LectureRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/repository/LectureRepository.java index b0cd9cc4..7f30e3c5 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/repository/LectureRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/repository/LectureRepository.java @@ -1,6 +1,5 @@ package intbyte4.learnsmate.lecture.repository; - import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.member.domain.entity.Member; import org.springframework.data.jpa.repository.JpaRepository; @@ -10,6 +9,6 @@ import java.util.List; @Repository -public interface LectureRepository extends JpaRepository , JpaSpecificationExecutor { +public interface LectureRepository extends JpaRepository , JpaSpecificationExecutor { List findAllByTutor(Member tutor); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/repository/LectureByStudentRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/repository/LectureByStudentRepository.java index c405d5c4..5fe15506 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/repository/LectureByStudentRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/repository/LectureByStudentRepository.java @@ -16,18 +16,18 @@ public interface LectureByStudentRepository extends JpaRepository findByStudentAndOwnStatus(Member student, boolean ownStatus); @Query("SELECT l.lectureByStudentCode FROM lecture_by_student l WHERE l.lecture.lectureCode = :lectureCode") - List findLectureByStudentCodesByLectureCode(@Param("lectureCode") Long lectureCode); + List findLectureByStudentCodesByLectureCode(@Param("lectureCode") String lectureCode); // 강의 코드와 ownStatus가 true인 수강생의 개수를 조회하는 쿼리 @Query("SELECT COUNT(ls) FROM lecture_by_student ls " + "WHERE ls.lecture.lectureCode = :lectureCode AND ls.ownStatus = true") - long countByLectureAndOwnStatus(@Param("lectureCode") Long lectureCode); + long countByLectureAndOwnStatus(@Param("lectureCode") String lectureCode); // 강의 코드로 학생별 강의에 대한 결제 금액을 합산하는 쿼리 @Query("SELECT SUM(p.paymentPrice) FROM payment p " + "JOIN p.lectureByStudent ls " + "WHERE ls.lecture.lectureCode = :lectureCode AND ls.ownStatus = true") - int calculateTotalRevenueByLecture(@Param("lectureCode") Long lectureCode); + int calculateTotalRevenueByLecture(@Param("lectureCode") String lectureCode); LectureByStudent findByLecture(Lecture lecture); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentService.java index 59255fca..5f17cbce 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentService.java @@ -12,9 +12,9 @@ public interface LectureByStudentService { List findByStudentCode(Long studentCode); // 강의별 학생코드 개수 조회 refund_status 가 true인것만 - long countStudentsByLectureAndOwnStatus(Long lectureCode); + long countStudentsByLectureAndOwnStatus(String lectureCode); - int calculateTotalRevenue(Long lectureCode); + int calculateTotalRevenue(String lectureCode); void registerLectureByStudent(LectureByStudentDTO lectureByStudentDTO, Lecture lecture, Member member); diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentServiceImpl.java index b2de921f..b68024cd 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_by_student/service/LectureByStudentServiceImpl.java @@ -47,14 +47,14 @@ public List findByStudentCode(Long studentCode) { // 강의별 학생코드 개수 조회 (ownStatus 가 true인것만) @Override - public long countStudentsByLectureAndOwnStatus(Long lectureCode) { + public long countStudentsByLectureAndOwnStatus(String lectureCode) { // 강의 코드에 해당하는 환불되지 않은 수강생의 개수를 조회 return lectureByStudentRepository.countByLectureAndOwnStatus(lectureCode); } // 강의 코드에 해당하는 결제 금액을 합산 @Override - public int calculateTotalRevenue(Long lectureCode) { + public int calculateTotalRevenue(String lectureCode) { return lectureByStudentRepository.calculateTotalRevenueByLecture(lectureCode); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/LectureCategoryByLectureDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/LectureCategoryByLectureDTO.java index 99b7a459..63590d37 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/LectureCategoryByLectureDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/LectureCategoryByLectureDTO.java @@ -12,6 +12,6 @@ public class LectureCategoryByLectureDTO { private Long lectureCategoryByLectureCode; - private Long lectureCode; + private String lectureCode; private Integer lectureCategoryCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/OneLectureCategoryListDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/OneLectureCategoryListDTO.java deleted file mode 100644 index 614faad6..00000000 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/dto/OneLectureCategoryListDTO.java +++ /dev/null @@ -1,16 +0,0 @@ -package intbyte4.learnsmate.lecture_category_by_lecture.domain.dto; - -import lombok.*; - -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -@ToString -public class OneLectureCategoryListDTO { - private Long lectureCode; - private List lectureCategoryCodeList; -} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/vo/response/ResponseFindLectureCategoryByLectureVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/vo/response/ResponseFindLectureCategoryByLectureVO.java index f2a86442..ebc57fb1 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/vo/response/ResponseFindLectureCategoryByLectureVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/domain/vo/response/ResponseFindLectureCategoryByLectureVO.java @@ -12,6 +12,6 @@ @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class ResponseFindLectureCategoryByLectureVO { private Long lectureCategoryByLectureCode; - private Long lectureCode; + private String lectureCode; private Integer lectureCategoryCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/repository/LectureCategoryByLectureRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/repository/LectureCategoryByLectureRepository.java index 93ea1e68..e8b99032 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/repository/LectureCategoryByLectureRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/repository/LectureCategoryByLectureRepository.java @@ -1,8 +1,10 @@ package intbyte4.learnsmate.lecture_category_by_lecture.repository; import intbyte4.learnsmate.lecture.domain.entity.Lecture; +import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.LectureCategoryByLectureDTO; import intbyte4.learnsmate.lecture_category_by_lecture.domain.entity.LectureCategoryByLecture; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @@ -15,7 +17,10 @@ public interface LectureCategoryByLectureRepository extends JpaRepository findCategoryNamesByLectureCode(@Param("lectureCode") Long lectureCode); + List findCategoryNamesByLectureCode(@Param("lectureCode") String lectureCode); - List findByLecture(Lecture lecture); + @Modifying + @Query("DELETE FROM lectureCategoryByLecture lcl " + + "WHERE lcl.lecture.lectureCode = :lectureCode") + void deleteAllByLectureCode(@Param("lectureCode") String lectureCode); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/domain/dto/LectureVideoProgressDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/domain/dto/LectureVideoProgressDTO.java index 8bf8d7c9..25d674be 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/domain/dto/LectureVideoProgressDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/domain/dto/LectureVideoProgressDTO.java @@ -10,7 +10,7 @@ @NoArgsConstructor @AllArgsConstructor public class LectureVideoProgressDTO { - private Long lectureCode; // 강의 코드 + private String lectureCode; // 강의 코드 private String lectureTitle; // 강의제목 private long totalVideos; // 총 동영상 수 private long completedVideos; // 완료된 동영상 수 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/repository/LectureVideoByStudentRepository.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/repository/LectureVideoByStudentRepository.java index 50a47f50..c65d9b87 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/repository/LectureVideoByStudentRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_video_by_student/repository/LectureVideoByStudentRepository.java @@ -10,10 +10,10 @@ public interface LectureVideoByStudentRepository extends JpaRepository getVideoProgressByStudent(Long studentCode) for (LectureByStudentDTO lectureByStudentDTO : lecturesByStudent) { // 각 강의의 강의 코드 - Long lectureCode = lectureByStudentDTO.getLectureByStudentCode(); + String lectureCode = lectureByStudentDTO.getLecture().getLectureCode(); // 강의에 속한 동영상 총 개수 조회 - long totalVideos = lectureVideoByStudentRepository.countByLectureCode(lectureCode); + int totalVideos = lectureVideoByStudentRepository.countByLectureCode(lectureCode); String lectureTitle = lectureByStudentDTO.getLecture().getLectureTitle(); // 완료된 동영상 수 조회 (lectureStatus가 true인 것만 카운트) - long completedVideos = lectureVideoByStudentRepository.countCompletedVideos(lectureCode); + int completedVideos = lectureVideoByStudentRepository.countCompletedVideos(lectureCode); // 진척도 계산 (완료된 동영상 수 / 총 동영상 수) double progress = totalVideos > 0 ? (double) completedVideos / totalVideos * 100 : 0; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java index 0f31a571..cf15a69c 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/dto/PaymentDetailDTO.java @@ -14,7 +14,7 @@ public class PaymentDetailDTO { private Long paymentCode; private Integer paymentPrice; private LocalDateTime createdAt; - private Long lectureCode; // 강의코드 + private String lectureCode; // 강의코드 private String lectureTitle; // 강의명 private Integer lecturePrice; // 강의 원가 private Long tutorCode; // 강사 코드 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java index 38516c31..8151ac22 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/PaymentFilterRequestVO.java @@ -27,8 +27,8 @@ public class PaymentFilterRequestVO { @JsonProperty("end_created_at") private LocalDateTime endCreatedAt; - @JsonProperty("leture_code") - private Long lectureCode; // 강의코드 + @JsonProperty("lecture_code") + private String lectureCode; // 강의코드 @JsonProperty("lecture_title") private String lectureTitle; // 강의명 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/ResponseFindPaymentVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/ResponseFindPaymentVO.java index 6a53f21c..f1be8302 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/ResponseFindPaymentVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/domain/vo/ResponseFindPaymentVO.java @@ -19,7 +19,7 @@ public class ResponseFindPaymentVO { private Long paymentCode; private Integer paymentPrice; private LocalDateTime createdAt; - private Long lectureCode; // 강의코드 + private String lectureCode; // 강의코드 private String lectureTitle; // 강의명 private Integer lecturePrice; // 강의 원가 private Long tutorCode; // 강사 코드 diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java index 15edd0be..56ac9000 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/payment/repository/CustomPaymentRepositoryImpl.java @@ -112,7 +112,7 @@ private BooleanExpression betweenCreatedAt(LocalDateTime startCreatedAt, LocalDa return QPayment.payment.createdAt.between(startCreatedAt, endCreatedAt); } - private BooleanExpression eqLectureCode(Long lectureCode) { + private BooleanExpression eqLectureCode(String lectureCode) { return lectureCode == null ? null : QPayment.payment.lectureByStudent.lecture.lectureCode.eq(lectureCode); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/controller/VideoByLectureController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/controller/VideoByLectureController.java index 617d4295..36122160 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/controller/VideoByLectureController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/controller/VideoByLectureController.java @@ -24,9 +24,7 @@ public class VideoByLectureController { @Operation(summary = "강의코드별 모든 강의별 동영상 조회") @GetMapping("/lectures/{lectureCode}/videos") - public ResponseEntity> findVideoByLectureByLectureCode( - @PathVariable("lectureCode") Long lectureCode) { - + public ResponseEntity> findVideoByLectureByLectureCode(@PathVariable("lectureCode") String lectureCode) { List videoByLectureDTOs = videoByLectureService.findVideoByLectureByLectureCode(lectureCode); List response = videoByLectureDTOs.stream() .map(videoByLectureMapper::toResponseVO) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/CountVideoByLectureDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/CountVideoByLectureDTO.java index 079585a0..76c8ae0a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/CountVideoByLectureDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/CountVideoByLectureDTO.java @@ -9,7 +9,7 @@ @NoArgsConstructor @AllArgsConstructor public class CountVideoByLectureDTO { - private Long lectureCode; + private String lectureCode; private String lectureTitle; private long videoCount; private long totalStudents; diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/VideoByLectureDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/VideoByLectureDTO.java index bd196fa8..014f16d1 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/VideoByLectureDTO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/dto/VideoByLectureDTO.java @@ -14,6 +14,6 @@ public class VideoByLectureDTO { private Long videoCode; private String videoLink; private String videoTitle; - private Long lectureCode; + private String lectureCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/vo/response/ResponseFindVideoByLectureVO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/vo/response/ResponseFindVideoByLectureVO.java index f3657f11..5667b700 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/vo/response/ResponseFindVideoByLectureVO.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/domain/vo/response/ResponseFindVideoByLectureVO.java @@ -16,5 +16,5 @@ public class ResponseFindVideoByLectureVO { private Long videoCode; private String videoLink; private String videoTitle; - private Long lectureCode; + private String lectureCode; } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java index d46bf665..eacd30d1 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureService.java @@ -6,10 +6,10 @@ public interface VideoByLectureService { // 강의코드별 모든 강의별 동영상 조회 - List findVideoByLectureByLectureCode(Long lectureCode); + List findVideoByLectureByLectureCode(String lectureCode); - void registerVideoByLecture(Long lectureCode, VideoByLectureDTO videoByLectureDTO); + void registerVideoByLecture(String lectureCode, VideoByLectureDTO videoByLectureDTO); // 동영상 제목과 링크 수정 메서드 - VideoByLectureDTO updateVideoByLecture(VideoByLectureDTO videoByLectureDTO); + void updateVideoByLecture(VideoByLectureDTO videoByLectureDTO); } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java index dc65c344..49be0bbb 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/video_by_lecture/service/VideoByLectureServiceImpl.java @@ -35,7 +35,7 @@ public class VideoByLectureServiceImpl implements VideoByLectureService { // 강의코드별 모든 강의별 동영상 조회 @Override - public List findVideoByLectureByLectureCode(Long lectureCode) { + public List findVideoByLectureByLectureCode(String lectureCode) { LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); @@ -55,8 +55,7 @@ public List findVideoByLectureByLectureCode(Long lectureCode) // 강의별 동영상 등록 @Override - public void registerVideoByLecture(Long lectureCode, VideoByLectureDTO videoByLectureDTO) { - + public void registerVideoByLecture(String lectureCode, VideoByLectureDTO videoByLectureDTO) { LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); @@ -65,7 +64,7 @@ public void registerVideoByLecture(Long lectureCode, VideoByLectureDTO videoByLe Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); VideoByLecture videoByLecture = VideoByLecture.builder() - .lecture(lecture) // 강의 설정 + .lecture(lecture) .videoTitle(videoByLectureDTO.getVideoTitle()) .videoLink(videoByLectureDTO.getVideoLink()) .build(); @@ -77,16 +76,13 @@ public void registerVideoByLecture(Long lectureCode, VideoByLectureDTO videoByLe // 동영상 제목과 링크 수정 메서드 @Override - public VideoByLectureDTO updateVideoByLecture(VideoByLectureDTO videoByLectureDTO) { - VideoByLecture videoByLecture = videoByLectureRepository.findById(videoByLectureDTO.getLectureCode()) + public void updateVideoByLecture(VideoByLectureDTO videoByLectureDTO) { + VideoByLecture videoByLecture = videoByLectureRepository.findById(videoByLectureDTO.getVideoCode()) .orElseThrow(() -> new CommonException(StatusEnum.VIDEO_BY_LECTURE_NOT_FOUND)); videoByLecture.toUpdate(videoByLectureDTO); VideoByLecture updatedVideoByLecture = videoByLectureRepository.save(videoByLecture); - return videoByLectureMapper.toDTO(updatedVideoByLecture); + videoByLectureMapper.toDTO(updatedVideoByLecture); } - - - } From b7f4ea4480c0aa68f6c0b63061fab909f2fd5118 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:09:04 +0900 Subject: [PATCH 08/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20lectureService=20-=20=ED=81=B4?= =?UTF-8?q?=EB=A6=AD=20=EC=88=98=20=EC=A6=9D=EA=B0=80=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C,=20=EC=9B=94=EB=B3=84/=EC=97=B0=EB=8F=84=EB=B3=84=20?= =?UTF-8?q?=EA=B0=95=EC=9D=98=20=EA=B0=9C=EC=88=98=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EA=B5=AC=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=9E=90=EB=A3=8C?= =?UTF-8?q?=ED=98=95=20=EB=B3=80=EA=B2=BD,=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/service/LectureService.java | 13 +++-- .../lecture/service/LectureServiceImpl.java | 53 ++++++++++--------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java index ca495e3c..bc66f310 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureService.java @@ -1,14 +1,21 @@ package intbyte4.learnsmate.lecture.service; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; +import intbyte4.learnsmate.lecture.domain.dto.MonthlyLectureCountDTO; import java.util.List; public interface LectureService { List getAllLecture(); - LectureDTO getLectureById(Long lectureCode); - LectureDTO getLecturesByStudentCode(Long studentCode); + + LectureDTO getLectureById(String lectureCode); + + void incrementClickCount(String lectureCode); + List getLecturesByTutorCode(Long tutorCode); - LectureDTO updateLectureConfirmStatus(Long lectureCode); + + void updateLectureConfirmStatus(String lectureCode); + + List getMonthlyLectureCounts(); } \ No newline at end of file diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java index 53f42bf9..4eac3a27 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureServiceImpl.java @@ -4,6 +4,7 @@ import intbyte4.learnsmate.common.exception.CommonException; import intbyte4.learnsmate.common.exception.StatusEnum; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; +import intbyte4.learnsmate.lecture.domain.dto.MonthlyLectureCountDTO; import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture.mapper.LectureMapper; import intbyte4.learnsmate.lecture.repository.LectureRepository; @@ -16,7 +17,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -28,7 +31,6 @@ public class LectureServiceImpl implements LectureService { private final MemberService memberService; private final MemberMapper memberMapper; - // 전체 강의 조회 @Override public List getAllLecture() { List lectureList = lectureRepository.findAll(); @@ -40,37 +42,25 @@ public List getAllLecture() { .collect(Collectors.toList()); } - // 강의 단건 조회 @Override - public LectureDTO getLectureById(Long lectureCode) { + public LectureDTO getLectureById(String lectureCode) { Lecture lecture = lectureRepository.findById(lectureCode) .orElseThrow(() -> new CommonException(StatusEnum.LECTURE_NOT_FOUND)); return lectureMapper.toDTO(lecture); } - // 유저별 조회에서 count++ lectureClickCount int 올리기 @Override - public LectureDTO getLecturesByStudentCode(Long studentCode) { - // 학생 정보 조회 - MemberDTO studentDTO = memberService.findMemberByMemberCode(studentCode, MemberType.STUDENT); - Member student = memberMapper.fromMemberDTOtoMember(studentDTO); + public void incrementClickCount(String lectureCode) { + LectureDTO lectureDTO = getLectureById(lectureCode); + lectureDTO.setLectureClickCount(lectureDTO.getLectureClickCount() + 1); - // 학생이 조회하려는 강의를 가져옴 - LectureDTO lectureDTO = getLectureById(studentCode); - - // 해당 강의의 클릭 수 증가 - Lecture lecture = lectureMapper.toEntity(lectureDTO,student); - lecture.incrementClickCount(); // 클릭 수를 증가시키는 메서드 추가 필요 + MemberDTO tutorDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); + Member tutor = memberMapper.fromMemberDTOtoMember(tutorDTO); + Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); - // 강의 정보 업데이트 lectureRepository.save(lecture); - - // 업데이트된 강의를 DTO로 변환하여 반환 - return lectureMapper.toDTO(lecture); } - - // 강사별 강의 모두 조회 @Override public List getLecturesByTutorCode(Long tutorCode) { MemberDTO tutorDTO = memberService.findMemberByMemberCode(tutorCode, MemberType.TUTOR); @@ -93,15 +83,30 @@ public List getLecturesByTutorCode(Long tutorCode) { // return lectureRepository.findAll(spec); // } - - // 강의별 계약과정이 강의 코드가 7개 라면 강의컬럼의 승인여부 true로 변환 @Override @Transactional - public LectureDTO updateLectureConfirmStatus(Long lectureCode) { + public void updateLectureConfirmStatus(String lectureCode) { Lecture lecture = lectureRepository.findById(lectureCode) .orElseThrow(() -> new CommonException(StatusEnum.LECTURE_NOT_FOUND)); lecture.toAcceptConfirmStatus(); lectureRepository.save(lecture); - return lectureMapper.toDTO(lecture); + lectureMapper.toDTO(lecture); + } + + @Override + public List getMonthlyLectureCounts() { + List lectures = lectureRepository.findAll(); + + Map groupedByMonth = lectures.stream() + .collect(Collectors.groupingBy( + lecture -> lecture.getCreatedAt().getYear() + "-" + + String.format("%02d", lecture.getCreatedAt().getMonthValue()), + Collectors.counting() + )); + + return groupedByMonth.entrySet().stream() + .map(entry -> new MonthlyLectureCountDTO(entry.getKey(), entry.getValue().intValue())) + .sorted(Comparator.comparing(MonthlyLectureCountDTO::getDate)) + .collect(Collectors.toList()); } } From 635bb5dec16179f082400fd569f4d18147323a60 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:09:18 +0900 Subject: [PATCH 09/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20=EC=9B=94=EB=B3=84/=EC=97=B0=EB=8F=84?= =?UTF-8?q?=EB=B3=84=20=EA=B0=95=EC=9D=98=20=EA=B0=9C=EC=88=98=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EC=9C=84=ED=95=9C=20DTO=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/domain/dto/MonthlyLectureCountDTO.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/MonthlyLectureCountDTO.java diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/MonthlyLectureCountDTO.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/MonthlyLectureCountDTO.java new file mode 100644 index 00000000..0fc30921 --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/domain/dto/MonthlyLectureCountDTO.java @@ -0,0 +1,14 @@ +package intbyte4.learnsmate.lecture.domain.dto; + +import lombok.*; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@ToString +@Builder +public class MonthlyLectureCountDTO { + private String date; + private int lectureCount; +} From fef062f7994b23f6054e32ba14ab6a360601ccf4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:09:36 +0900 Subject: [PATCH 10/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20=ED=8D=BC=EC=82=AC=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/service/LectureFacade.java | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java index 8a33cfd1..93f3af48 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/service/LectureFacade.java @@ -25,7 +25,6 @@ import intbyte4.learnsmate.lecture_by_student.domain.entity.LectureByStudent; import intbyte4.learnsmate.lecture_by_student.repository.LectureByStudentRepository; import intbyte4.learnsmate.lecture_by_student.service.LectureByStudentService; -import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.OneLectureCategoryListDTO; import intbyte4.learnsmate.lecture_category_by_lecture.service.LectureCategoryByLectureService; import intbyte4.learnsmate.member.domain.MemberType; import intbyte4.learnsmate.member.domain.dto.MemberDTO; @@ -38,9 +37,11 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.time.format.DateTimeFormatter; import java.util.List; import java.time.LocalDateTime; +import java.util.UUID; import java.util.stream.Collectors; @Service @@ -112,7 +113,7 @@ private record Result(LectureDTO lectureDTO, Member tutor, Lecture lecture, Issu } @Transactional - public LectureDTO removeLecture(Long lectureCode) { + public LectureDTO removeLecture(String lectureCode) { Lecture lecture = lectureRepository.findById(lectureCode) .orElseThrow(() -> new CommonException(StatusEnum.LECTURE_NOT_FOUND)); lecture.toDelete(); @@ -133,15 +134,11 @@ public void updateOwnStatus(Lecture lecture) { lectureByStudentRepository.saveAll(lectureByStudents); } - @Transactional public LectureDTO registerLecture(LectureDTO lectureDTO, List lectureCategoryCodeList, List videoByLectureDTOList) { - - // 강의를 담당하는 튜터 정보 조회 및 변환 MemberDTO memberDTO = memberService.findMemberByMemberCode(lectureDTO.getTutorCode(), MemberType.TUTOR); Member tutor = memberMapper.fromMemberDTOtoMember(memberDTO); - // 강의 엔티티 생성 및 저장 Lecture lecture = Lecture.builder() .lectureTitle(lectureDTO.getLectureTitle()) .lectureConfirmStatus(false) @@ -155,39 +152,42 @@ public LectureDTO registerLecture(LectureDTO lectureDTO, List lectureCa .lectureLevel(LectureLevelEnum.valueOf(lectureDTO.getLectureLevel())) .build(); + setLectureCode(lecture, lectureCategoryCodeList); lectureRepository.save(lecture); - // 강의별 카테고리 등록 - OneLectureCategoryListDTO oneLectureCategoryListDTO - = new OneLectureCategoryListDTO(lecture.getLectureCode(), lectureCategoryCodeList); - lectureCategoryByLectureService.saveLectureCategoryByLecture(oneLectureCategoryListDTO); - - Long lectureCode = lecture.getLectureCode(); + for (Integer lectureCategoryCode : lectureCategoryCodeList) { + lectureCategoryByLectureService.saveLectureCategoryByLecture(lecture.getLectureCode(), lectureCategoryCode); + } - videoByLectureDTOList.forEach(videoDTO -> { - videoByLectureService.registerVideoByLecture(lectureCode, videoDTO); - }); + videoByLectureDTOList.forEach(videoDTO -> videoByLectureService.registerVideoByLecture(lecture.getLectureCode(), videoDTO)); - // 강의 정보 DTO로 변환하여 반환 return lectureMapper.toDTO(lecture); } + private void setLectureCode(Lecture lecture, List lectureCategoryCodeList) { + String lectureCodePrefix; + String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); + String randomUUID = UUID.randomUUID().toString().substring(0, 8); + + if (lectureCategoryCodeList.contains(7)) lectureCodePrefix = "L007"; + else if (lectureCategoryCodeList.size() > 1) lectureCodePrefix = "Lmul"; + else lectureCodePrefix = "L" + String.format("%03d", lectureCategoryCodeList.get(0)); + + lecture.setLectureCode(lectureCodePrefix + "-" + date + "-" + randomUUID); + } + - // 강의 모두 조회 public List getAllLecture() { List lectureList = lectureService.getAllLecture(); - if (lectureList.isEmpty()) { - throw new CommonException(StatusEnum.LECTURE_NOT_FOUND); - } + if (lectureList.isEmpty()) throw new CommonException(StatusEnum.LECTURE_NOT_FOUND); return lectureList.stream() .map(this::buildLectureDetailDTO) .collect(Collectors.toList()); } - // 강의 단건 조회 - public LectureDetailDTO getLectureById(Long lectureCode) { + public LectureDetailDTO getLectureById(String lectureCode) { LectureDTO lecture = lectureService.getLectureById(lectureCode); if (lecture == null) { throw new CommonException(StatusEnum.LECTURE_NOT_FOUND); @@ -225,12 +225,9 @@ private LectureDetailDTO buildLectureDetailDTO(LectureDTO lecture) { public LectureDTO updateLecture(LectureDTO lectureDTO, String newVideoTitle, String newVideoLink, List lectureCategoryCodeList) { Lecture lecture = lectureRepository.findById(lectureDTO.getLectureCode()) .orElseThrow(() -> new CommonException(StatusEnum.LECTURE_NOT_FOUND)); - - // 강의 정보 업데이트 lecture.toUpdate(lectureDTO); lectureRepository.save(lecture); - // 비디오 정보 업데이트 List videoByLectureDTOs = videoByLectureService.findVideoByLectureByLectureCode(lectureDTO.getLectureCode()); for (VideoByLectureDTO videoDTO : videoByLectureDTOs) { VideoByLectureDTO updatedVideoDTO = VideoByLectureDTO.builder() @@ -238,20 +235,17 @@ public LectureDTO updateLecture(LectureDTO lectureDTO, String newVideoTitle, Str .videoTitle(newVideoTitle) .videoLink(newVideoLink) .build(); - videoByLectureService.updateVideoByLecture(updatedVideoDTO); } - // 강의 카테고리 수정 - if (lectureCategoryCodeList != null && !lectureCategoryCodeList.isEmpty()) { - OneLectureCategoryListDTO categoryDTO = new OneLectureCategoryListDTO(); - categoryDTO.setLectureCode(lectureDTO.getLectureCode()); - categoryDTO.setLectureCategoryCodeList(lectureCategoryCodeList); - lectureCategoryByLectureService.updateLectureCategoryByLecture(categoryDTO); + if (!lectureCategoryCodeList.isEmpty()) { + lectureCategoryByLectureService.deleteByLectureCode(lecture.getLectureCode()); + + for (Integer lectureCategoryCode : lectureCategoryCodeList) { + lectureCategoryByLectureService.saveLectureCategoryByLecture(lecture.getLectureCode(), lectureCategoryCode); + } } return lectureMapper.toDTO(lecture); } - - } \ No newline at end of file From 5c81a23b7fce9dc0ebd2a8688103f39707bb6af3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:13:06 +0900 Subject: [PATCH 11/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20=EB=A7=A4=ED=8D=BC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20-=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A7=8C=20?= =?UTF-8?q?=EA=B0=80=EC=A7=80=EA=B3=A0=20update=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java index fb7b20aa..654a0f9e 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java @@ -78,12 +78,9 @@ public ResponseFindLectureVO fromDtoToResponseVO(LectureDetailDTO dto) { public LectureDTO fromRequestVOtoDto(RequestEditLectureInfoVO vo) { return LectureDTO.builder() .lectureTitle(vo.getLectureTitle()) - .lectureConfirmStatus(vo.getLectureConfirmStatus()) .updatedAt(LocalDateTime.now()) .lectureImage(vo.getLectureImage()) .lecturePrice(vo.getLecturePrice()) - .lectureStatus(vo.getLectureStatus()) - .lectureClickCount(vo.getLectureClickCount()) .lectureLevel(String.valueOf(vo.getLectureLevel())) .build(); } From 99046624ab41983a179680e3a4186bd661a0084b Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:13:46 +0900 Subject: [PATCH 12/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20:=20=EA=B0=95=EC=9D=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=9B=94?= =?UTF-8?q?=EB=B3=84/=EC=97=B0=EB=8F=84=EB=B3=84=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/controller/LectureController.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java index c2f9202c..0aabe0d8 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/controller/LectureController.java @@ -1,5 +1,6 @@ package intbyte4.learnsmate.lecture.controller; +import intbyte4.learnsmate.lecture.domain.dto.MonthlyLectureCountDTO; import intbyte4.learnsmate.lecture.service.LectureFacade; import intbyte4.learnsmate.lecture.domain.dto.LectureDTO; import intbyte4.learnsmate.lecture.domain.dto.LectureDetailDTO; @@ -33,10 +34,10 @@ public class LectureController { private final LectureFacade lectureFacade; @Operation(summary = "학생이 강의를 클릭할 때 클릭 수 증가") - @PostMapping("/{lectureCode}/click") - public ResponseEntity incrementClickCount(@PathVariable("lectureCode") Long lectureCode) { + @PatchMapping("/{lectureCode}/click") + public ResponseEntity incrementClickCount(@PathVariable("lectureCode") String lectureCode) { try { - lectureService.getLecturesByStudentCode(lectureCode); + lectureService.incrementClickCount(lectureCode); return ResponseEntity.status(HttpStatus.OK).build(); } catch (Exception e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); @@ -55,51 +56,46 @@ public ResponseEntity> getAllLectures() { @Operation(summary = "강의 단건 조회") @GetMapping("/{lectureCode}") - public ResponseEntity getLecture(@PathVariable("lectureCode") Long lectureCode) { + public ResponseEntity getLecture(@PathVariable("lectureCode") String lectureCode) { LectureDetailDTO lectureDTO = lectureFacade.getLectureById(lectureCode); return ResponseEntity.status(HttpStatus.OK).body(lectureMapper.fromDtoToResponseVO(lectureDTO)); } - @Operation(summary = "강의와 강의별 동영상, 강의별 카테고리 및 동영상 등록") - @PutMapping("/{lectureCode}") - public ResponseEntity registerLecture( - @RequestBody RequestRegisterLectureVO registerLectureVO) { - + @Operation(summary = "강의와 강의별 동영상 등록 요청") + @PostMapping("/register") + public ResponseEntity registerLecture(@RequestBody RequestRegisterLectureVO registerLectureVO) { LectureDTO lectureDTO = lectureMapper.fromRegisterRequestVOtoDto(registerLectureVO); List lectureCategoryCodeList = registerLectureVO.getLectureCategoryCodeList(); List videoByLectureDTOList = registerLectureVO.getVideoByLectureDTOList(); LectureDTO registeredLectureDTO = lectureFacade.registerLecture(lectureDTO, lectureCategoryCodeList, videoByLectureDTOList); - return ResponseEntity.status(HttpStatus.CREATED) - .body(lectureMapper.fromDtoToRegisterResponseVO(registeredLectureDTO)); + return ResponseEntity.status(HttpStatus.CREATED).body(lectureMapper.fromDtoToRegisterResponseVO(registeredLectureDTO)); } - @Operation(summary = "강의 수정") @PatchMapping("/{lectureCode}/info") - public ResponseEntity updateLecture( - @RequestBody RequestEditLectureInfoVO requestVO) { - + public ResponseEntity updateLecture(@RequestBody RequestEditLectureInfoVO requestVO, @PathVariable String lectureCode) { LectureDTO lectureDTO = lectureMapper.fromRequestVOtoDto(requestVO); + lectureDTO.setLectureCode(lectureCode); - LectureDTO updatedLecture = lectureFacade.updateLecture(lectureDTO, - requestVO.getNewVideoTitle(), - requestVO.getNewVideoLink(), - requestVO.getLectureCategoryCodeList()); + LectureDTO updatedLecture = lectureFacade.updateLecture(lectureDTO, requestVO.getNewVideoTitle(), requestVO.getNewVideoLink(), requestVO.getLectureCategoryCodeList()); ResponseEditLectureInfoVO responseVO = lectureMapper.fromDtoToEditResponseVO(updatedLecture); - return ResponseEntity.status(HttpStatus.CREATED).body(responseVO); } - - @Operation(summary = "강의 삭제") @PatchMapping("/{lectureCode}/status") - public ResponseEntity removeLecture(@PathVariable("lectureCode") Long lectureCode) { + public ResponseEntity removeLecture(@PathVariable("lectureCode") String lectureCode) { LectureDTO removedLecture = lectureFacade.removeLecture(lectureCode); return ResponseEntity.status(HttpStatus.OK).body(lectureMapper.fromDtoToRemoveResponseVO(removedLecture)); } + @Operation(summary = "월별/연도별 전체 강의 수 조회") + @GetMapping("/monthly-counts") + public ResponseEntity> getMonthlyLectureCounts() { + List lectureCounts = lectureService.getMonthlyLectureCounts(); + return ResponseEntity.ok(lectureCounts); + } } From cce7c775ef284ed2dcc32e159d6d599903aa0044 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:14:42 +0900 Subject: [PATCH 13/14] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20:=20=EA=B0=95=EC=9D=98=20=EB=B3=84=20?= =?UTF-8?q?=EA=B0=95=EC=9D=98=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LectureCategoryByLectureMapper.java | 23 +----- .../LectureCategoryByLectureService.java | 81 ++++--------------- 2 files changed, 17 insertions(+), 87 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java index f23e012f..e0d43b2a 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java @@ -3,7 +3,6 @@ import intbyte4.learnsmate.lecture.domain.entity.Lecture; import intbyte4.learnsmate.lecture_category.domain.entity.LectureCategory; import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.LectureCategoryByLectureDTO; -import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.OneLectureCategoryListDTO; import intbyte4.learnsmate.lecture_category_by_lecture.domain.entity.LectureCategoryByLecture; import intbyte4.learnsmate.lecture_category_by_lecture.domain.vo.response.ResponseFindLectureCategoryByLectureVO; import org.springframework.stereotype.Component; @@ -14,7 +13,7 @@ @Component public class LectureCategoryByLectureMapper { - public List fromEntitytoDTO(List entityList) { + public List fromEntityToDTO(List entityList) { return entityList.stream() .map(entity -> LectureCategoryByLectureDTO.builder() .lectureCategoryByLectureCode(entity.getLectureCategoryByLectureCode()) @@ -33,24 +32,4 @@ public List fromDTOtoFindVO(List fromLectureAndLectureCategoryListtoEntity(Lecture lecture, List categoryList) { - return categoryList.stream() - .map(lectureCategory -> LectureCategoryByLecture.builder() - .lecture(lecture) - .lectureCategory(lectureCategory) - .build() - ) - .collect(Collectors.toList()); - } - - public List fromLectureAndLectureCategoryListToEntity(Lecture lecture, List lectureCategoryList) { - return lectureCategoryList.stream() - .map(lectureCategory -> LectureCategoryByLecture.builder() - .lecture(lecture) - .lectureCategory(lectureCategory) - .build() - ) - .collect(Collectors.toList()); - } } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java index c8c212b4..1703ced6 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/service/LectureCategoryByLectureService.java @@ -11,7 +11,6 @@ import intbyte4.learnsmate.lecture_category.mapper.LectureCategoryMapper; import intbyte4.learnsmate.lecture_category.service.LectureCategoryService; import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.LectureCategoryByLectureDTO; -import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.OneLectureCategoryListDTO; import intbyte4.learnsmate.lecture_category_by_lecture.domain.entity.LectureCategoryByLecture; import intbyte4.learnsmate.lecture_category_by_lecture.mapper.LectureCategoryByLectureMapper; import intbyte4.learnsmate.lecture_category_by_lecture.repository.LectureCategoryByLectureRepository; @@ -20,11 +19,10 @@ import intbyte4.learnsmate.member.domain.entity.Member; import intbyte4.learnsmate.member.mapper.MemberMapper; import intbyte4.learnsmate.member.service.MemberService; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.util.ArrayList; - import java.util.List; @Service @@ -41,91 +39,44 @@ public class LectureCategoryByLectureService { private final LectureCategoryService lectureCategoryService; private final LectureCategoryMapper lectureCategoryMapper; - // 모든 강의별 강의 카테고리 조회 메서드 public List findAll() { List entityList = lectureCategoryByLectureRepository.findAll(); - return lectureCategoryByLectureMapper.fromEntitytoDTO(entityList); + return lectureCategoryByLectureMapper.fromEntityToDTO(entityList); } - // 특정 강의별 강의 카테고리 조회 메서드 public LectureCategoryByLectureDTO findById(Long code) { LectureCategoryByLecture entity = lectureCategoryByLectureRepository.findById(code) .orElseThrow(() -> new CommonException(StatusEnum.LECTURE_CATEGORY_BY_LECTURE_NOT_FOUND)); - return lectureCategoryByLectureMapper.fromEntitytoDTO(List.of(entity)).get(0); + return lectureCategoryByLectureMapper.fromEntityToDTO(List.of(entity)).get(0); } - // 특정 강의에 강의 카테고리 추가 메서드 -> 어떤 dto를 써야할까? OneLectureCategoryListDTO - public void saveLectureCategoryByLecture(OneLectureCategoryListDTO dto){ - - // 어떠한 강의 - LectureDTO lectureDTO = lectureService.getLectureById(dto.getLectureCode()); - - // 강의 안에있는 멤버 + public void saveLectureCategoryByLecture(String lectureCode, Integer lectureCategoryCode){ + LectureDTO lectureDTO = lectureService.getLectureById(lectureCode); MemberDTO memberDTO = memberService.findById(lectureDTO.getTutorCode()); Member tutor = memberMapper.fromMemberDTOtoMember(memberDTO); - // 강의 완성 Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); - // 여러개의 강의 카테고리 - List lectureCategoryList = new ArrayList<>(); - for (int i = 0; i < dto.getLectureCategoryCodeList().size(); i++) { - LectureCategoryDTO categoryDTO = lectureCategoryService.findByLectureCategoryCode(dto.getLectureCategoryCodeList().get(i)); - LectureCategory lectureCategory = lectureCategoryMapper.toEntity(categoryDTO); - lectureCategoryList.add(lectureCategory); - } + LectureCategoryDTO lectureCategoryDTO = lectureCategoryService.findByLectureCategoryCode(lectureCategoryCode); + LectureCategory lectureCategory = lectureCategoryMapper.toEntity(lectureCategoryDTO); - // 등록할 강의별 강의 카테고리 완성 - List entitytList - = lectureCategoryByLectureMapper.fromLectureAndLectureCategoryListtoEntity(lecture, lectureCategoryList); + LectureCategoryByLecture lectureCategoryByLecture = LectureCategoryByLecture.builder() + .lecture(lecture) + .lectureCategory(lectureCategory) + .build(); - // 강의별 강의 카테고리 테이블에 저장 - lectureCategoryByLectureRepository.saveAll(entitytList); + lectureCategoryByLectureRepository.save(lectureCategoryByLecture); } - public List findCategoryNamesByLectureCode(Long lectureCode) { + public List findCategoryNamesByLectureCode(String lectureCode) { return lectureCategoryByLectureRepository.findCategoryNamesByLectureCode(lectureCode); } - - // 강의와 카테고리 간 관계 업데이트 메서드 - public void updateLectureCategoryByLecture(OneLectureCategoryListDTO dto) { - // 해당 강의 정보 가져오기 - LectureDTO lectureDTO = lectureService.getLectureById(dto.getLectureCode()); - - // 강의의 멤버 (강사) 정보 가져오기 - MemberDTO memberDTO = memberService.findById(lectureDTO.getTutorCode()); - Member tutor = memberMapper.fromMemberDTOtoMember(memberDTO); - - // 강의 엔티티로 변환 - Lecture lecture = lectureMapper.toEntity(lectureDTO, tutor); - - // 수정할 강의 카테고리 목록 - List lectureCategoryList = new ArrayList<>(); - for (int categoryCode : dto.getLectureCategoryCodeList()) { - // 카테고리 DTO 가져오기 - LectureCategoryDTO categoryDTO = lectureCategoryService.findByLectureCategoryCode(categoryCode); - // 카테고리 엔티티로 변환 - LectureCategory lectureCategory = lectureCategoryMapper.toEntity(categoryDTO); - lectureCategoryList.add(lectureCategory); - } - - // 기존 강의와 연결된 카테고리들 찾기 - List existingCategories = lectureCategoryByLectureRepository.findByLecture(lecture); - if (!existingCategories.isEmpty()) { - // 기존 카테고리 삭제 - lectureCategoryByLectureRepository.deleteAll(existingCategories); - } - - // 새로 연결할 강의별 강의 카테고리 엔티티 생성 - List entityList = lectureCategoryByLectureMapper.fromLectureAndLectureCategoryListToEntity(lecture, lectureCategoryList); - - // 강의별 강의 카테고리 테이블에 저장 - lectureCategoryByLectureRepository.saveAll(entityList); + @Transactional + public void deleteByLectureCode(String lectureCode) { + lectureCategoryByLectureRepository.deleteAllByLectureCode(lectureCode); } - - } From 06fe1c6a49d088b66db4c0795ed463dbf02ba74b Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Fri, 15 Nov 2024 20:14:55 +0900 Subject: [PATCH 14/14] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/LectureCategoryByLectureMapper.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java index e0d43b2a..cef98982 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture_category_by_lecture/mapper/LectureCategoryByLectureMapper.java @@ -1,7 +1,5 @@ package intbyte4.learnsmate.lecture_category_by_lecture.mapper; -import intbyte4.learnsmate.lecture.domain.entity.Lecture; -import intbyte4.learnsmate.lecture_category.domain.entity.LectureCategory; import intbyte4.learnsmate.lecture_category_by_lecture.domain.dto.LectureCategoryByLectureDTO; import intbyte4.learnsmate.lecture_category_by_lecture.domain.entity.LectureCategoryByLecture; import intbyte4.learnsmate.lecture_category_by_lecture.domain.vo.response.ResponseFindLectureCategoryByLectureVO;