From 3c4581182ffac3d442598e7bd4ef2509296a1f33 Mon Sep 17 00:00:00 2001 From: "DESKTOP-BC2AP8U\\Playdata" Date: Thu, 21 Nov 2024 14:51:30 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=EA=B8=B0=EB=8A=A5=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20:=20Mapper,=20DTO,=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98,=20Repository=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/domain/dto/LectureDetailDTO.java | 2 +- .../lecture/mapper/LectureMapper.java | 15 -------- .../pagination/CursorPaginationResponse.java | 16 --------- .../LectureCursorPaginationResponse.java | 36 +++++++++++++++++++ .../lecture/repository/LectureRepository.java | 4 +++ 5 files changed, 41 insertions(+), 32 deletions(-) delete mode 100644 LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/CursorPaginationResponse.java create mode 100644 LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/LectureCursorPaginationResponse.java 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 77677097..5f974590 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 @@ -22,7 +22,7 @@ public class LectureDetailDTO { private Long tutorCode; private String tutorName; private Boolean lectureStatus; - private String lectureCategory; + private String lectureCategoryName; private Integer lectureClickCount; private String lectureLevel; private int totalStudents; 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 76dca89f..01069e42 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/mapper/LectureMapper.java @@ -51,20 +51,6 @@ public Lecture toEntity(LectureDTO dto, Member tutor) { .build(); } - public ResponseFindLectureVO fromDtoToResponseVO(LectureDetailDTO dto) { - return ResponseFindLectureVO.builder() - .lectureCode(dto.getLectureCode()) - .lectureTitle(dto.getLectureTitle()) - .lectureConfirmStatus(dto.getLectureConfirmStatus()) - .createdAt(dto.getCreatedAt()) - .lecturePrice(dto.getLecturePrice()) - .tutorCode(dto.getTutorCode()) - .tutorName(dto.getTutorName()) - .lectureStatus(dto.getLectureStatus()) - .lectureLevel(LectureLevelEnum.valueOf(dto.getLectureLevel())) - .build(); - } - public LectureDTO fromRequestVOtoDto(RequestEditLectureInfoVO vo) { return LectureDTO.builder() .lectureTitle(vo.getLectureTitle()) @@ -147,5 +133,4 @@ public LectureDTO fromRequestRegisterLecturePaymentVOToDTO(RequestRegisterLectur .lectureLevel(String.valueOf(vo.getLectureLevel())) .build(); } - } diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/CursorPaginationResponse.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/CursorPaginationResponse.java deleted file mode 100644 index ef62a07b..00000000 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/CursorPaginationResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package intbyte4.learnsmate.lecture.pagination; - -import lombok.*; - -import java.time.LocalDateTime; -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class CursorPaginationResponse { - private List data; - private LocalDateTime nextCursor; -} diff --git a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/LectureCursorPaginationResponse.java b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/LectureCursorPaginationResponse.java new file mode 100644 index 00000000..567d0b62 --- /dev/null +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/pagination/LectureCursorPaginationResponse.java @@ -0,0 +1,36 @@ +package intbyte4.learnsmate.lecture.pagination; + +import lombok.*; + +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class LectureCursorPaginationResponse { + private List data; + private LocalDateTime nextCursor; + private int currentPage; + private int pageSize; + private boolean hasNext; + + public static LectureCursorPaginationResponse ofCursor(List data, LocalDateTime nextCursor) { + return LectureCursorPaginationResponse.builder() + .data(data) + .nextCursor(nextCursor) + .hasNext(nextCursor != null) + .build(); + } + + public static LectureCursorPaginationResponse ofOffset(List data, int currentPage, int pageSize, boolean hasNext) { + return LectureCursorPaginationResponse.builder() + .data(data) + .currentPage(currentPage) + .pageSize(pageSize) + .hasNext(hasNext) + .build(); + } +} 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 28ed789e..368ed574 100644 --- a/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/repository/LectureRepository.java +++ b/LearnsMate/src/main/java/intbyte4/learnsmate/lecture/repository/LectureRepository.java @@ -16,9 +16,13 @@ public interface LectureRepository extends JpaRepository , JpaSpecificationExecutor { List findAllByTutor(Member tutor); + @Query("SELECT l FROM lecture l ORDER BY l.createdAt DESC") + List findLecturesByOffset(Pageable pageable); + @Query("SELECT l FROM lecture l WHERE (:cursor IS NULL OR l.createdAt < :cursor) ORDER BY l.createdAt DESC") List findLecturesByCursor(@Param("cursor") LocalDateTime cursor, Pageable pageable); + @Query("SELECT CONCAT(YEAR(l.createdAt), '-', LPAD(CAST(MONTH(l.createdAt) AS string), 2, '0')) AS monthYear, COUNT(l) " + "FROM lecture l " + "GROUP BY YEAR(l.createdAt), MONTH(l.createdAt) " +