Skip to content

Commit

Permalink
✨ 기능 수정 : Mapper, DTO, 페이지네이션, Repository 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJeHuni committed Nov 21, 2024
1 parent be27dd3 commit 3c45811
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -147,5 +133,4 @@ public LectureDTO fromRequestRegisterLecturePaymentVOToDTO(RequestRegisterLectur
.lectureLevel(String.valueOf(vo.getLectureLevel()))
.build();
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<T> {
private List<T> data;
private LocalDateTime nextCursor;
private int currentPage;
private int pageSize;
private boolean hasNext;

public static <T> LectureCursorPaginationResponse<T> ofCursor(List<T> data, LocalDateTime nextCursor) {
return LectureCursorPaginationResponse.<T>builder()
.data(data)
.nextCursor(nextCursor)
.hasNext(nextCursor != null)
.build();
}

public static <T> LectureCursorPaginationResponse<T> ofOffset(List<T> data, int currentPage, int pageSize, boolean hasNext) {
return LectureCursorPaginationResponse.<T>builder()
.data(data)
.currentPage(currentPage)
.pageSize(pageSize)
.hasNext(hasNext)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
public interface LectureRepository extends JpaRepository<Lecture, String> , JpaSpecificationExecutor<Lecture> {
List<Lecture> findAllByTutor(Member tutor);

@Query("SELECT l FROM lecture l ORDER BY l.createdAt DESC")
List<Lecture> findLecturesByOffset(Pageable pageable);

@Query("SELECT l FROM lecture l WHERE (:cursor IS NULL OR l.createdAt < :cursor) ORDER BY l.createdAt DESC")
List<Lecture> 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) " +
Expand Down

0 comments on commit 3c45811

Please sign in to comment.